Home > .Net, Tutorial for Beginners > ADO.net Tutorial for beginners

ADO.net Tutorial for beginners

Ado.net:  Ado.net is the new technology and used to connect with different datasource. It provides interoperability and scalable data access by XML. So we can say if any application who can read the XML can process data. It is the new invention of Microsoft to fulfill the today’s application development requirement. Now days web applications are not tightly coupled, they have become loosely coupled web application model. All web applications are xml based.  Ado.net provide disconnected model along with tight integration with XML, Ado.net is based on Microsoft Active X Object (ADO).  It supports n Tier applications with the help of DataSet. Ado.net is based on XML. Means it uses xml for everything for example data encoding and data access.  Here everything is handle at the client side which increate the performance.

It is integral part of .Net Framework.  You can connect with your data source using Ado.net.  ADO.net has two main components as

  • Data provider
  • DataSet

Data Provider:  Ado.net provides the way to connect with the database, there are lots of database like SQL Server, Oracle, DB2, MS Access etc.  Data provider is the way to connect with these data source.  We can choose the correct protocol as per the used data source. Ado.net provides Data Provider For

  • SQL Client – to connect with SQL Server (System.Data.SqlClient)
  • OracleClient – to connect with Oracle server(System.Data.OracleClient)
  • ODBC – used to connect with the older database(System.Data.Odbc)
  • OLEDB – Used to connect with Excel or MsAccess(System.data.OLEDB)

Ado.net Object model is divided into two categories

      • Connected Environment &
      • DataSet(Disconnected environment)

      ADO.Net Objects: 

    Like Data Providers, ado.net objects are not different, they are common and used as it is with all data provider.  Below is the list of all available components

  • Connection (SqlConnection):  this method is used to make connection with database from .Net application. You can do it as

    SqlConnection objCon = newSqlConnection



    Above line reads the connection string settings from web config and will return the connection object in objCon,You can define your connection string setting in Web.config as

    <addkey="strConnect"value="Data Source=Dell-PC\SQLEXPRESS;
            initial catalog=TestDB;Integrated Security =True;"/>
  • Command (SqlCommand):With the help of this command you can communicate with the database. You can directly pass the query or you can use “Stroed Procedure”.  With the help of command type (Text, Stored Procedure, DirectTable) you can choose whether you are going to use plain SQL Query or Stored Procedure.

    SqlCommand cmd = newSqlCommand("Your Query", objCon);

  • DataReader (SqlDataReader):  It gives you read only access on your data, you can store your data but could not modify.

SqlDataAdapter DA = new SqlDataAdapter(cmd);


       DataSet ds = new DataSet();


  • DataAdaptor (SqlAdaptor): It is used to fill the dataset and send the update to the database server. It is used to fetch and retrieve the data. It holds the data in memory than pass it to Dataset. It is used for write and read purpose.

while (dr.Read())


 //so some code


Read also: Datasets in C#

Post Comments Below

  1. No comments yet.
  1. No trackbacks yet.