Posted on 12/22/2020 5:37:22 AM by Admin

Pillars of Ado.Net

If you have gone through my previous article what is Ado.Net then you must be knowing that Ado.Net is nothing but a set of libraries. It wouldn't be wrong to say that it is a collection of some classes and in order to communicate with any data source, we just need to create the related object and call the required methods.

There are different data providers which help to interact with the different data sources for example to communicate with SQL Server we have System.Data.SqlClient and similarly for Oracle, we have System.Data.OracleClient.

Each of these data providers contains 4 main classes, which are the pillars of Ado.Net.

Connection Class

It is used to establish an open connection to the corresponding Data Source. It is a sealed class so that cannot be inherited. depending on the provider, the different connection classes are
    • SQLConnection: to establish an open connection to the SQL Server database.
    • OracleConnection : to establish an open connection to the Oracle database
    • OleDbConnection: to establish an open connection to the OleDb Data Source like Excel and Access.
    • OdbcConnection : to establish an open connection to the Odbc Data Source.
   

Command Class

This class is used to store and execute SQL statement for corresponding database. It is a sealed class so that cannot be inherited. Depending on the provider , the different command classes are
    • SQLCommand: to store and execute SQL statement for SQL Server database.
    • OracleCommand : to store and execute SQL statement for the Oracle database
    • OleDbCommand:- to store and execute SQL statement for OleDb Data Source like Excel and Access.
    • OdbcCommand: to store and execute SQL statement for Odbc Data Source.

DataReader Class

This class is used to read data from the corresponding database. It reads data in a forward-only stream of rows from a SQL Server database. it is a sealed class so that cannot be inherited. It inherits the DbDataReader class and implements the IDisposable interface. Depending on the provider, the different DataReader classes are
    • SQLDataReader: to read data from SQL Server database.
    • OracleDataReader: to read data from the Oracle database
    • OleDbDataReader: to read data from OleDb Data Source like Excel and Access.
    • OdbcDataReader: to read data from Odbc Data Source.

DataAdapter Class

The DataAdapter works as a bridge between a DataSet and a data source to retrieve data. DataAdapter is a class that represents a set of SQL commands and a database connection. It can be used to fill the DataSet and update the data source. Depending on the provider , the different DataAdapter classes are
    • SQLDataAdapter: bridge between a DataSet and SQL Server database.
    • OracleDataAdapter: bridge between a DataSet and Oracle database
    • OleDbDataAdapter: bridge between a DataSet and OleDb Data Source like Excel and Access.
    • OdbcDataAdapter: bridge between a DataSet and Odbc Data Source.

we will discuss each of this one by one in upcoming articles.