Introduction to ADO.NET and Application development

Sep 14 • Notes • 2091 Views • No Comments on Introduction to ADO.NET and Application development

ADO .NET consists of a set of classes defined by .NET framework. A framework can be defined as a process or any media through which we can develop, manage and control any webpage or any website. ADO.net can also be used to access the data from the database. The current version of ADO.net is ADO.net 2.0 developed by Microsoft. In this section, we have discussed all the basic concepts of ADO.NET and also application development using ADO.NET, Object Creation in ADO.NET, Visual Basic Code for Object creation and at the bottom interview question on C# is attached with it for freshers. Still if it contains any error please do let us know through the comments. Any type of suggestions will be highly appreciated. 

Introduction to ADO.NET. 

ado.net

Basic Concepts of ADO.NET

As we have discussed earlier, ADO.NET consists of a set of classes that are defined by .NET framework. ADO stands for ActiveX Data Objects. It is the primary data access API for .NET framework. It provides the classes which can be used to develop database applications with visual basic as well as .NET framework. We can use these classes for accessing and updating the databases.

Develop Database Applications with ADO.NET

The only way to develop the database applications with ADO.NET is to use the datasets. Through this, the application gets data from a database and store it in the dataset that is kept in cache memory on disk. Now, the application is able to add, update, delete the data from the database which are stored in the database as well as stored in the cache memory. Later it can save the changes in the respective database.

Data Adapter 

There is an important aspect of data adapter. To load data into the data table , the data adapter can be used. The main function of the data adapter is to manage the flow of data between a dataset and a database. For this function, data adapter uses certain commands that define the SQL statements to be issued. For example, the command for retrieve data from database, normally defines the SELECT statement. Then the command connects to the database using a connection and passes the SELECT statement to the database. After the SELECT statement is executed, the result is sent back to the data adapter. The data adapter stores the results in the  data table.

Types of Data Provider in ADO.NET.

ADO.NET has different types of data providers which allow a way to interact with the data source. These are specially the class libraries. The data providers are listed below.

a.  ODBC Data Provider
b.  OLEDB Data Provider
c.   ORACLE data provider
d.   SQL data provider
e.   Borland data provider

Functions of Data Providers

  • The first data provider is ODBC data provider. Its API prefix is ODBC. These are the data sources with an ODBC interface. These are normally older data bases.
  • The next one is OLEDB data provider. The API prefix is assigned as oledb for it. It is the data source that exposes an OLEDB interface like access or excel.
  • The API prefix for ORACLE data provider is oracle. These type of data sources are used for oracle databases.
  • The API prefix for SQL data provider is sql. These types of data providers are normally used for interfacing with Microsoft SQL Server.
  • The last one is Borland data provider. Its API prefix is bdp. These types of data sources are the generic access to many databases like SQL server, oracle, etc.

ADO.NET Objects

ADO.net includes many objects that are used to work with data. There are certain steps for create an ADO.NET object. These are as follows:

  • The .NET data provider provides the classes that we can create objects that can be used to retrieve the data from the database and store the data into the database.
  • One way to work with a database when we use ADO.NET is to retrieve the data from the database into a dataset and store the data from the dataset into the database.
  • A dataset contains one or more data tables that store the retrieved data from the database.
  • When we use a data adapter to work with a database, the data provider remains connected to the database .

Creating ADO.NET Objects

There are certain ways to create ADO.NET objects that can be used to work with data. We can create the ADO.NET objects from a data source that is shown in the data sources window. Data sources are use to create forms in a simpler way that work with the data in a data source.

Once we create the data source, we can rag it onto a form to add controls and to create ADO.NET objects for working with the data in the data source.

VB code for Creating ADO.NET Objects

The visual basic code for create an ADO.NET object is follows:

Dim connection String As String = “Data Source =localhost\SqlExpress;
Initial Catalog=Payables; ”
Dim connection As New SqlConnection(connectionString)
Dim select Statement As New String= “SELECT * from terms ” 

Dim select Command As New SqlCommand(selectStatement, connection)
Dim terms DataAdapter As New SqlAdapter (selectCommand)
Dim terms DataSet As New DataSet

Different Types of ADO.Net objects

Different types of objects that are defined on ADO.NET are

  • The SqlConnection Object 
  • The SqlCommand Object
  • The SqlDataReader Object
  • The DataSet Object
  • The SqlDataAdapter Object

Define certain .NET data provider core objects.

Certain .NET data provider core objects are listed below.

  • Connection:- This object establishes a connection to a database.
  • Command:- It represents an individual SQL statement that can be executed.
  • Data Reader:- It provides read-only, forward-only access to the data in the database.
  • Data Adapter:- it provides the link between the command and connection objects and a dataset object.

 Related Links
1. Interview Questions on C#
2. Questions on C# 

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

« »