No reference is maintained between the DataSet, the DataAdapter, and the Connection. After the DataAdapter retrieves data from a data source into a DataSet, the DataSet has no information about the connection, database, tables, columns, or any other details about the source of the data.
Because the DataAdapter is a connected class, each .NET data provider implements its own DataAdapter, with a similar interface and function to other DataAdapter classes but in its own unique namespace. The DataAdapter class namespaces for several ADO.NET data providers are listed in Table 29-1.
Class |
Data source |
---|---|
System.Data.SqlClient.SqlDataAdapter |
SQL Server |
System.Data.OleDb.OleDbDataAdapter |
OLE DB provider |
Microsoft.Data.Odbc.OdbcDataAdapter |
ODBC driver |
System.Data.OracleClient.OracleDataAdapter |
Oracle |
The commonly used public properties of the DataAdapter class are listed in Table 29-2.
Property |
Description |
---|---|
AcceptChangesDuringFill |
Gets or sets a value indicating whether the row is committed when added to a table using the Fill( ) method. |
ContinueUpdateOnError |
Gets or sets a value indicating whether the DataAdapter should raise an exception and stop processing remaining updates when an error is encountered. |
DeleteCommand |
Gets or sets the command, either a SQL statement or a stored procedure, that deletes the DataSet records marked for deletion from the data source when using the Update( ) method. |
InsertCommand |
Gets or sets the command, either a SQL statement or a stored procedure, that inserts new DataSet records into the data source when using the Update( ) method. |
MissingMappingAction |
Specifies the action to take when columns or tables in the incoming data from the data source don't have matching columns or tables in the DataSet. |
MissingSchemaAction |
Specifies the action to take when the schema of the data source doesn't match the DataSet schema. |
SelectCommand |
Gets or sets the command, either a SQL statement or a stored procedure, that selects records from the data source when using the Fill( ) method. |
UpdateCommand |
Gets or sets the command, either a SQL statement or a stored procedure, that updates modified Dataset records in the data source when using the Update( ) method. |
The commonly used public collections of the DataAdapter class are listed in Table 29-3.
Collection |
Description |
---|---|
TableMappings |
Accesses the DataTableMappingCollection, which contains table and column name mapping information for reconciling the disconnected data with the data source, as a collection of DataTableMapping objects. |
The commonly used public methods of the DataAdapter class are listed in Table 29-4.
Method |
Description |
---|---|
Fill( ) |
Adds new rows or refreshes rows in the DataSet with data from the data source. |
FillSchema( ) |
Adds an empty table to the DataSet and configures its schema to match the data source. |
GetFillParameters( ) |
Returns an array of parameter objects for the SelectCommand. |
Update( ) |
Submits changes in the DataSet to the data source for reconciliation. |
The commonly used public events of the DataAdapter class are listed in Table 29-5.
Event |
Description |
---|---|
FillError |
Raised when an error is encountered during a Fill( ) operation. |
RowUpdating |
Raised before the command to reconcile a DataSet row with the data source row has been executed. |
RowUpdated |
Raised after the command to reconcile a DataSet row with the data source row has been executed. |
The DataAdapter class inherits from Component and implements the IDataAdapter interface. Public static members of this class are safe for multithreaded operations; instance members aren't guaranteed to be thread-safe.