ADO.NET Introduction
It is a module of .Net Framework which is used to establish connection between application and data sources. Data sources can be such as SQL Server and XML. ADO.NET consists of classes that can be used to connect, retrieve, insert and delete data.
All the ADO.NET classes are located into System.Data.dll and integrated with XML classes located into System.Xml.dll.
ADO.NET has two main components that are used for accessing and manipulating data are the .NET Framework data provider and the DataSet.
.NET Framework Data Providers
These are the components that are designed for data manipulation and fast access to data. It provides various objects such as Connection, Command, DataReader and DataAdapter that are used to perform database operations. We will have a detailed discussion about Data Providers in new topic.
The DataSet
It is used to access data independently from any data resource. DataSet contains a collection of one or more DataTable objects of data. The following diagram shows the relationship between .NET Framework data provider and DataSet.
Fig: ADO.NET Architecture
Which one should we use DataReader or DataSet?
We should consider the following points to use DataSet.
- It caches data locally at our application, so we can manipulate it.
- It interacts with data dynamically such as binding to windows forms control.
- It allows performing processing on data without an open connection. It means it can work while connection is disconnected.
If we required some other functionality mentioned above, we can use DataReader to improve performance of our application.
DataReader does not perform in disconnected mode. It requires DataReader object to be connected.