ADO.Net Data Access Model for ASP.Net-Part 2
In the first part of ADO.Net data access model for ASP.Net we discussed about Connection, Command and DataReader that enables you to connect to the data source and retrieve data. For using DataReader the open connection state has to be maintained to for retrieving the data and represent in the application.
Disconnected Data Access Model
In this part we will learn about second type of model i.e. Disconnected Data Access model of ADO.Net. This data access approach does not need to keep an open connection to database. This Data Access Model includes the following classes:
It executes to fill the DataSet in-memory by retrieved data from the data source.
It represents the in-memory Data Table retrieved using DataAdapter that fills the DataSet containing the Relational DataTable hierarchy.
It represents the in-memory view of database table that can be modified using filters to represent the DataTable with different views.
It represents the in-memory database retrieved by using DataAdapter.
At the backend DataAdapter uses DataReader to retrieve the data from the database. It automatically opens and closes the database connection. If the database connection is already open before its execution then DataAdapter leaves it open after being executed.
Further these classed provide the functionality to generate the views of DataTable created by retrieving the data from database table. You can filter DataTable into DataView to represent the data according to the requirements.
Disadvantage of using these objects is slow performance due to large usage of memory for storing number records. For comparison between DataReader and DataAdapter, DataReader works much faster than DataAdapter for retrieving more than 1000 records at a time.
Above discussed Disconnected Data Access component DataAdapter has names according to their providers.
SqlDataAdapter, OleDbDataAdapter, ODBCDataAdpater
Other Objects DataView, DataTable and DataSet are common for all data providers and comes under same namespace i.e. System.Data.
Continue to next tutorial: Stored Procedures Vs Dynamic SQL Queries in ASP.Net to learn about the benefits of using stored procedures over SQL queries.