Disconnected Data Access Architecture

The ADO.NET Framework offers support for two distinct models of Data Access Architecture: Connection Oriented Data Access Architecture and Disconnected Data Access Architecture. Among these, the ADO.NET Disconnected Data Access Architecture stands out as a significantly more flexible and robust alternative to ADO's Connection Oriented approach.

Connection Oriented Data Access

In Connection Oriented Data Access Architecture, the application establishes a connection to the Data Source and interacts with it by sending SQL requests through the same connection. Consequently, the application remains connected to the database system even during periods of inactivity when no Database Operations are being performed. In contrast, the disconnected approach takes a different route by relinquishing the need to maintain a continuous connection to the data source.

To address these concerns, ADO.NET introduces a vital component known as the Dataset. Within the ADO.NET Disconnected Data Access Architecture, the Dataset assumes a central role. It serves as an in-memory data store capable of accommodating multiple tables simultaneously. Importantly, the Dataset focuses solely on holding data and does not engage in direct interactions with a specific Data Source. Notably, the Dataset exhibits a remarkable characteristic in that it possesses no knowledge of the underlying Data Source that may have been employed to populate its contents.

Disconnected Data Access

The Disconnected Data Access Architecture provided by ADO.NET revolutionizes the way data is accessed and manipulated. By introducing the Dataset as a versatile in-memory repository, ADO.NET grants developers greater flexibility and independence in managing data. The Dataset's ability to handle multiple tables concurrently, coupled with its detachment from the specifics of the underlying Data Source, contributes to an efficient and adaptable data access framework.

VB.Net

Dim ds As New DataSet

C#

DataSet ds = new DataSet();

Considering Connection Oriented Data Access, it is essential to maintain an open connection between your application and the Data Source when reading data using a DataReader object. This direct connection enables real-time retrieval of data from the Data Source.

However, in contrast to the DataReader, the DataSet does not establish a direct connection to the Data Source through a Connection object when it is being populated. Instead, it is the responsibility of the DataAdapter to handle the connection management between the Data Source and the DataSet. The DataAdapter facilitates the transfer of data from the Data Source to the DataSet, effectively imparting a disconnected behavior to the DataSet.

VB.Net

Dim adapter As New SqlDataAdapter("sql", "connection") Dim ds As New DataSet adapter.Fill(ds, "Src Table")

C#

SqlDataAdapter adapter = new SqlDataAdapter("sql", "connection"); DataSet ds = new DataSet(); adapter.Fill(ds, "Src Table");

By utilizing the DataAdapter, the connection between the Connected Objects (such as the Data Source and the DataReader) and the Disconnected Objects (such as the DataSet) is bridged. The DataAdapter acts as a mediator, facilitating the transfer of data from the Data Source to the DataSet. This enables the DataSet to operate independently of the Data Source, allowing for enhanced flexibility and versatility in manipulating and managing the data within the application.

Conclusion

In Connection Oriented Data Access, maintaining an open connection is necessary when using a DataReader to read data directly from the Data Source. In contrast, the DataSet does not establish a direct connection. Instead, the DataAdapter manages the connection between the Data Source and the DataSet, enabling a disconnected behavior for the DataSet and serving as a bridge between the Connected and Disconnected Objects in the data access process.