13-04-2012, 12:42 PM
ADO.NET
ADO.NET (3).ppt (Size: 656.5 KB / Downloads: 46)
ADO.NET is the Successor to Active-x Data Object (ADO 2.6)
We can use ADO in .NET Framework but our performance will be slow when working with COM Layer, Because .NET Framework does not support COM Variant Type an ADO use’s it for Field & Recordset Obj.
If we use the ADO Recordset in .NET then every time CLR have to perform Type-Conversion for each Field & this Type-Conversion can become costly when working with Databases.
You will get a truly disconnected data architecture.
Tight Integration with XML.
A common Representation with ability to combine data from Different Databases.
Goals of ADO.NET
Current ADO Knowledge
Support N-Tier Programming Model.
Provide support for XML.
Easy to create Distributed, Data sharing Application
Provide Interface to communicate with OLEDB Data source such as SQL Server & Oracle.
In Distributed Application there is a concept of Disconnected data. ADO.NET uses XML to exchange data between program or with web page that means it enables programmer to easily separate the data processing and interface on separate server. That will improve performance and maintainability of system.
Once you get the Data the connection with D.S is dropped after you can work with Data Locally.
So, It frees up the DB server Resources.
ADO.NET Components
There are two components of ADO.NET that you can use to access and manipulate data:
.NET Framework data providers
The DataSet
.NET Framework Data Providers
The .NET Framework Data Providers are components that have been explicitly designed for data manipulation and fast, forward-only, read-only access to data.
1) The Connection object provides connectivity to a data source.
2) The Command object enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information.
3) The DataReader provides a high-performance stream of data from the data source.
4) The DataAdapter provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL commands at the data source to both load the DataSet with data, and reconcile changes made to the data in the DataSet back to the data source.
Choosing a DataReader or a DataSet
If you do not require the functionality provided by the DataSet, you can improve the performance of your application by using the DataReader to return your data in a forward-only, read-only fashion.
Although the DataAdapter uses the DataReader to fill the contents of a DataSet
By using the DataReader you can boost performance because you will save memory that would be consumed by the DataSet, as well as avoid the processing required to create and fill the contents of the DataSet.
Properties & Methods of Interest
Collections are used to add & remove tables & relations
Properties of Interest:
Tables: Returns the collection of DataTable objects
Relations: Returns the collection of DataRelations
Using Properties Samples:
myDataSet.Tables.Add( myTable );
myDataTableCollection = myDataSet.Tables
The DataTable
May be mapped to a physical table in the data source
Can be related to one another through DataRelations
Optimistic concurrency or locking - model
Properties of Interest:
Columns: Returns ColumnsCollection of DataColumns
Rows: Returns DataRow objects as a RowsCollection
ParentRelations: Returns the RelationsCollection
Constraints: Returns the table’s ConstraintsCollection
DataSet: Returns the DataSet of the DataTable
PrimaryKey: Gets the DataColumns that make up the table’s primary key