4.1.1

Although a DataSet provides a stand-alone entity separate from the underlying store, in most cases it will get its data from a managed provider whose role is to connect, fill, and persist the DataSet to and from a data store. .NET offers two such providers embodied in the following two namespaces:

System.Data.SqlClientUsed to talk directly to Microsoft SQL Server.

System.Data.OleDbUsed to talk to any other provider that supports OLE DB (a COM-based API for accessing data).

For the most part, both namespaces provide the same important classes which represent the following major ADO.NET objects:

ConnectionRepresents a connection to a data source.

CommandRepresents an executable SQL statement or stored procedure.

DataReaderFacilitates the reading of a forward-only stream of rows from a database.

DataAdapterRepresents a set of commands and a connection which can be used to fill a DataSet and update the underlying data store.

Depending on the provider used, these ADO.NET objects have different class names, as shown in table 4.1.

Table 4.1 The ADO.NET objects

ADO.NET Object

System.Data.SqlClient Class

System.Data.OleDb Class

Connection

SqlConnection

OleDbConnection

Command

SqlCommand

OleDbCommand

DataReader

SqlDataReader

OleDbDataReader

DataAdapter

SqlDataAdapter

OleDbDataAdapter

The ADO.NET namespaces