Managed Providers
As you saw in Chapter 31, .NET is based on a common runtime engine for all software running on the platform. The common language runtime takes good care of your code. It manages memory for you, provides interop services for you, and makes your code execute safely and securely.The runtime doesn't provide native data access functionality, but .NET ships with a pair of managed database providers. The managed providers are represented by several classes that are members of the common runtime class library. The data access classes are known collectively as ADO.NET.The ADO.NET DataReader class enables you to retrieve a forward-only and read-only stream of data from a database. The DataSet class provides an in-memory copy of data retrieved from a database. You can think of a DataSet object as a disconnected recordset in ADO. ADO.NET currently has no provision for server-side cursors. Some applications don't need this capability. Any applications that require server-side cursors can use the classic ADO recordset through the COM interop layer. The samples accompanying Visual Studio .NET include an ADO interop example. The example is included in the Microsoft Visual Studio .NET \FrameworkSDK\Samples\Technologies\Interop\Basic\ASPXToADO directory.
.NET Managed Providers
As far as ADO.NET is concerned, there are basically two kinds of databases: Microsoft SQL Server databases and all other databases that implement OLEDB. The SQL Server managed provider classes run within the common language runtime; the OLEDB managed provider uses native OLEDB and the COM interop layer to establish a connection to a data store.ADO.NET includes the following basic functionality for working with databases: creating datasets, connecting to databases, issuing commands, reading data streams, and using data adapters to exchange data between a data source and a dataset. ADO.NET divides the functionality into interfaces and implementations. That is, there's a single connection interface, a single command interface, and a single data adapter interface. However, ADO.NET furnishes separate implementations of each of these interfaces. The managed data providers are generally divided into the System::Data::SqlClient namespace and the System::Data::OleDb namespace. Table 35-1 shows the ADO.NET interfaces and their separate implementations.
Interface | SQL Server Implementation | OLEDB Implementation |
---|---|---|
IDbConnection | SqlConnection | OleDbConnection |
IDataAdapter | SqlDataAdapter | OleDbDataAdapter |
IDbCommand | SqlCommand | OleDbCommand |
IDataReader | SqlDataReader | OleDbDataReader |
IDataRecord | SqlDataRecord | OleDbDataRecord |
IDataParameter | SqlDataParameter | OleDbDataParameter |
Figure 35-1 shows the relationship between the ADO.NET managed providers, SQL Server, OLEDB providers, and COM.

Figure 35-1: The relationship between the ADO.NET managed providers, SQL Server, OLEDB providers, and COM.