ADO.NET

ActiveX Data Objects

ADO.NET stands for ActiveX Data Objects.NET.  ADO.NET is a set of objects, built into VB.NET, that allow you to write code to access data outside of your application. At first sight ADO.NET seems complicated, with its various objects such as the Connection, DataAdapter, DataSet and DataTable. But it is here in which the flexibility of ADO.NET lies. The same program code can be written to manipulate data from a wide range of different external data sources such as SQL Server, Oracle and Microsoft Access to name but a few.

In summary:

  • ADO.NET is a set of objects that allow your application to access external data
  • Data from different sources can be accessed in the same way (SQL Server, MS Access, Oracle, …)
  • ADO.NET allows connected or disconnected access to data

Disconnected access to data

Although ADO.NET allows an application to establish a ‘live’ link between with an external data source, one of the design goals of ADO.NET was to allow an application to establish a connection, retrieve some data, then close the connection and work with the data while disconnected.

Data is returned in the form of a DataSet object which contains at least one DataTable. A DataTable contains DataRows and DataColumns.

The DataSet is actually a memory resident copy of a subset of the data in the database. A DataSet can contain multiple DataTables and even the relationships between them, which are known as DataRelations.

ADO.NET Architecture

The ADO.NET architecture is represented here. It illustrates the various objects and how they are related to each other.

You can see that the DataSet is a memory resident copy of a subset of the data in a database. The DataSet can contain one or more tables and even the relationships between the tables. Each DataTable contains DataRows and DataColumns. It can also contain Constraints, otherwise known as validation rules.
Behind the scenes, the data in a DataSet in in XML format (eXtensible Markup Language) which is particularly useful for web developers who wish to use it on web pages.

ADO.NET objects

You will find that once you have written some code to successfully retrieve data from a database, or to save new data into a database, you will not need to write this code again from scratch, you will find yourself copying and pasting it into new applications and modifying it accordingly. You will eventually become quite skilled in the use of the various ADO.NET objects if you write this kind of application a lot.

DataReader

Used with the Command object to retrieve results sequentially from a database as the SQL query executes.

DataAdapter

A bridge between the DataReader and the DataSet. Used to fill a DataSet with query results.

Dataset

A disconnected, memory resident, subset of the data retrieved from a database.  The DataSet contains one or more DataTables, which contain DataRows and DataColumns.