Vous êtes sur la page 1sur 5

ADO .

NET ARCHITECTURE:

ADO .Net uses structured process flow containing components. Data in


datasource is retrieved using various component of data provider and provide
data to an application, then update changes back to database. ADO .NET
classes are in system.data namespace and used in application by importing, for
instance,
Using system.data (C#)

ADO .NET clearly factors data access from data manipulation.

Key components :

Dataset
Data Provider

Dataset handles data access. Data Manipulation is taken care by .Net data
provider.
DATASET:
It is an in-memory representation of data. It can be used with multiple and
differing data sources such as XML file or stream, data local to application.
Dataset can be used if an application meets any of the following requirement:

- Remote data access


- Multiple and differing data sources
- Cache data local to the application
- Provide hierarchical XML view of a relational data and use XSL,Xpath tools
- Disconnected data access.

1
DATA PROVIDER:

Data in datasource is retrieved using various components of data provider and


provide data to applicationa and update the changes back to datasource.

Components of Data Provider

Connection
Command
Data adapter
Data Reader

CONNECTION OBJECT:

It establishes connection to data store. Oledb connection object, Sql Connection


object are the two types of connection object.

OLEDB Connection works with almost all datasource SQL Connection Object
specifically works with Microsoft SQL Server 7.0 or later.

Properties of Connection Object:

Connection String:

It is a primary property. Connection String provides information like data


provider, data source, database name, Integrated Security and so on. For
instance,

Provider=SqlOledb1;Data Source=MySqlServer;Initial Catalog= Northwind;


Integrated Security=SSPI

Integrated Security specifies NT authentication to be used. Instead userid and


password attribute can be used which is not a recommended practice since it
leads to potential security breach.

State Property:

It provides information about current state of the connection object. State


Property value zero specifies connection is closed and 1 indicates connection is
open.

COMMAND OBJECT:
Data from data source is obtained by executing commands using command
objects.

2
Property of Command Object:
Command Text Property:

It possess Sql Statement or name of the Stored Procedure to perform the


command.

Command Type Property:

It contains stored procedure setting or text setting or table direct.Table Direct


returns entire table. This setting applies only to OLEDB .Net Providers.

Command Object provides several execute methods namely execute scalar,


execute reader, execute nonquery method. Let’s have a brief look into its
function.

Execute Scalar:

Performs query commands that return a single value. For example, counting the
number of records in a table.

Execute Non Query:

Executes commands that returns the number of rows affected by the command.

Execute Reader:

It reads records sequentially from the database.

DATA ADAPTER:

It acts as a bridge between data source and data set to retrieve data and
reconciles data back to the database. Oledb data adapter works with Oledb
provider. Sql data adapter which is specific to Sql Server is faster than Oledb
data adapter because it need not go through Oledb layer.

It exchanges data between single data source and single data table object in the
data set. To work with multiple tables in dataset multiple data adapter should
be used. To populate a table in dataset, data adapter can be called which
execute Sql Statement or Stored Procedure. Data Adapter supports Select
Command, Insert Command, Update Command and Delete Command
Properties.

DATA READER:

Data Reader can be used to increase the performance of the application which
works in read-only, forward-only mode.

3
DATA TABLE , COLUMN , ROW

A DataSet is made up of a collection of tables, relationships, and constraints. In


ADO.NET, DataTable objects are used to represent the tables in a DataSet. A
DataTable represents one table of in-memory relational data; the data is local
to the .NET-based application in which it resides, but can be populated from a
data source such as Microsoft SQL Server using a DataAdapter For more
information, see Populating a DataSet from a DataAdapter.

The DataTable class is a member of the System.Data namespace within the


.NET Framework class library. You can create and use a DataTable
independently or as a member of a DataSet, and DataTable objects can also be
used in conjunction with other .NET Framework objects, including the
DataView. You access the collection of tables in a DataSet through the Tables
property of the DataSet object.

The schema, or structure of a table is represented by columns and constraints.


You define the schema of a DataTable using DataColumn objects as well as
ForeignKeyConstraint and UniqueConstraint objects. The columns in a table
can map to columns in a data source, contain calculated values from
expressions, automatically increment their values, or contain primary key
values.

In addition to a schema, a DataTable must also have rows to contain and order
data. The DataRow class represents the actual data contained in a table. You
use the DataRow and its properties and methods to retrieve, evaluate, and
manipulate the data in a table. As you access and change the data within a row,
the DataRow object maintains both its current and original state.

DATA VIEW

A DataView enables you to create different views of the data stored in a


DataTable, a capability that is often used in data-binding applications. Using a
DataView, you can expose the data in a table with different sort orders, and
you can filter the data by row state or based on a filter expression.

A DataView provides a dynamic view of data in the underlying DataTable:


the content, ordering, and membership reflect changes as they occur. This
behavior differs from the Select method of the DataTable, which returns a
DataRow array from a table based on a particular filter and/or sort order:
thiscontent reflects changes to the underlying table, but its membership and
ordering remain static. The dynamic capabilities of the DataView make it ideal
for data-binding applications.

A DataView provides you with a dynamic view of a single set of data, much
like a database view, to which you can apply different sorting and filtering
criteria. Unlike a database view, however, a DataView cannot be treated as a
4
table and cannot provide a view of joined tables. You also cannot exclude
columns that exist in the source table, nor can you append columns, such as
computational columns, that do not exist in the source table.

You can use a DataViewManager to manage view settings for all the tables in a
DataSet. The DataViewManager provides you with a convenient way to
manage default view settings for each table. When binding a control to more
than one table of a DataSet, binding to a DataViewManager is the ideal
choice.

DATA RELATION

A DataRelation is used to relate two DataTable objects to each other through


DataColumn objects. For example, in a Customer/Orders relationship, the
Customers table is the parent and the Orders table is the child of the
relationship. This is similar to a primary key/foreign key relationship. For more
information, see Navigating a Relationship between Tables.

Relationships are created between matching columns in the parent and child
tables. That is, the DataType value for both columns must be identical.

Relationships can also cascade various changes from the parent DataRow to its
child rows. To control how values are changed in child rows, add a
ForeignKeyConstraint to the ConstraintCollection of the DataTable object.
The ConstraintCollection determines what action to take when a value in a
parent table is deleted or updated.

When a DataRelation is created, it first verifies that the relationship can be


established. After it is added to the DataRelationCollection, the relationship is
maintained by disallowing any changes that would invalidate it. Between the
period when a DataRelation is created and added to the
DataRelationCollection, it is possible for additional changes to be made to the
parent or child rows. An exception is generated if this results in a relationship
that is no longer valid.

DataRelation objects are contained in a DataRelationCollection, which you


can access through the Relations property of the DataSet, and the
ChildRelations and ParentRelations properties of the DataTable.

Vous aimerez peut-être aussi