ADO.NET Disconnected Architecture

  1. Difference between Connected Architecture and Disconnected Architecture
  2. DataReader and DataSet.
  3. Features of DataSet
  4. Working with DataSet
  5. Methods of DataAdapter
  6. Accessing data from DataSet
  7. DataTable
  8. Referring to a cell under DataTable
Let's start with the details.
ADO.NET provides the following two models for accessing data from a Data Source:
  1. Connection-Oriented Architecture
  2. Disconnected Oriented Architecture
1. Connection-Oriented Architecture
In this case, we require a continuous connection with the Data Source for accessing data in it.
Here the “DataReader” class holds the data on client machines.
2. Disconnected Oriented Architecture
In this case, we do not require a continuous connection with the Data Source for accessing data.
Here the “DataSet” class holds the data in the client machines.


It is a class present under the “System.Data” namespace design for holding and managing data on client machines apart from a DataReader.
Features Of DataSet
  1. It is also capable of holding multiple tables.
  2. It is a designed disconnected architecture that doesn't require a permanent connection with a Data Source for holding data.
  3. It provides scrollable navigation to data, that allows us to move in any direction.
    In other words, either top to bottom or bottom to top.
  4. It is updatable, in other words, changes can be performed to data present in it and also send changes back to the DB.
Working With DataSet
This class is responsible for the loading of data into a DataReader from a DataSource and is a command.
In the same way, the DataAdapter class is used for communication between a DataSource and DataSet.
DataReader < - Command -> DataSource.
DataSet <->DataAdapter <->DataSource.
Methods of DataAdapter
  1. Fill (DataSet ds,string TableName).
  2. Update (DataSet ds,string TableName)
Fill in the method to load data from a DataSource into a DataSet.
Update is to transfer data from a DataSet to a DataSource.
DataAdapter is internally a collection of the following 4 methods:
  1. Select Command.
  2. Insert Command.
  3. Update Command.
  4. Delete Command.
When we call the Fill() method of Adapter, the following action takes place internally.
  1. Open a connection with the DataSource.
  2. Execute the Select command under it on the DataSource and loads data from the table to the DataSet.
  3. Close the Connection.
Siince a DataSet is updatable, changes can be made to data that is loaded into it, like adding, modifying and deleting records.
After making all the changes to the data in a dataset if we want to send those changes back to the DataSource then call the Update() method on the DataAdapter that performed the following:
  1. Re-opened a connection with the DataSource.
  2. Changes made in the dataset will be sent back to the table where in this process it will use the insert, update and delete commands of the DataAdapter.
  3. Close the Connection.
Accessing Data From DataSet
DataReader provides us a pointer vases access to the data, so we can get data only in sequential order, whereas a dataset provides us index-based access to data so we can get the data from any location.
Dataset is a collection of tables where each table is represented as a DataTable class and identified by the index position.
DataTable is the collection of tables.
The following syntax is used for a DataTable:
For example:
Every DataTable is again a collection of Rows and Columns where each row is represented as a DataRow class and identified by its index position.
Each column is represented as a DataColumn class and identified by index position or name.
It is a collection of rows.
For example:
It is a collection of Columns.
<datatable>.Columns[Index] OR columns[Name]
For example:
The following is the syntax for referring to a cell under a Data Table:
<datatable>.Rows[row] [col]
For example:
For more articles visit my blog: