In this article, I am going to discuss ADO.NET Architecture. Please read our previous article where we discussed ADO.NET Connection Pooling with Examples.
What is ADO.NET?
ADO stands for Active Data Objects. ADO is nothing but a component in .NET Framework that helps us to fetch data from different data sources to our C# and VB.NET code and probably you can send data from your C# or VB.NET code to different data sources.
The architecture of ADO.NET:
The ADO.NET Architecture is comprising of 6 important components. They are as follows:
From the above components, two components are compulsory. One is the command object and the other one is the connection object. Irrespective of the operations like Insert, Update, Delete and Select, the command and connection object you always need. For better understanding, please have a look at the following image.
Let us understand each of the components in detail.
The first important component is the connection object. The connection object is required to connect with your backend database which can be SQL Server, Oracle, MySQL, etc. To create a connection object, you need at least two things. The first one is where is your database located i.e. the Machine name or IP Address or someplace where your database is located. And the second thing is the security credentials i.e. whether it is a windows authentication or user name and password-based authentication. So, the first is to create the connection object and the connection is required to connect to the backend data source.
The second important component is the command object. When we talk about databases like SQL Server, Oracle, MySQL, then understand SQL. The command object is the component where you go and write your SQL queries. Later you take the command object and execute it over the connection. Then you can fetch data or send data to the database using the command object and SQL queries.
Note: From the command object onwards, you can go in two different ways. One is you can go with the DataSet way and the other is, you can go with the DataReader way. Which way you need to choose, basically it will depend on the situation.
DataReader is a read-only connected recordset that helps us to read the records only in the forward mode. Here, you need to understand three things i.e. read-only, connected, and forward mode.
It is a disconnected recordset that can be browsed in both i.e. forward and backward. It is also possible to update via dataset. DataSet gets filled by somebody called DataAdapter.
The DataAdapter acts as a bridge between the command object and the dataset. What the DataAdapter does, it takes the data from the command object and fills the data set.
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.
In the next article, I am going to discuss ADO.NET Distributed Transactions with Examples. Here, in this article, I try to explain ADO.NET Architecture and I hope you enjoy this ADO.NET Architecture article.