Muokkaa

Jaa


DataAdapters and DataReaders

You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Results are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the DataReader. Using the DataReader can increase application performance both by retrieving data as soon as it is available, and (by default) storing only one row at a time in memory, reducing system overhead.

A DataAdapter is used to retrieve data from a data source and populate tables within a DataSet. The DataAdapter also resolves changes made to the DataSet back to the data source. The DataAdapter uses the Connection object of the .NET Framework data provider to connect to a data source, and it uses Command objects to retrieve data from and resolve changes to the data source.

Each .NET Framework data provider included with the .NET Framework has a DbDataReader and a DbDataAdapter object: the .NET Framework Data Provider for OLE DB includes an OleDbDataReader and an OleDbDataAdapter object, the .NET Framework Data Provider for SQL Server includes a SqlDataReader and a SqlDataAdapter object, the .NET Framework Data Provider for ODBC includes an OdbcDataReader and an OdbcDataAdapter object, and the .NET Framework Data Provider for Oracle includes an OracleDataReader and an OracleDataAdapter object.

In This Section

Retrieving Data Using a DataReader
Describes the ADO.NET DataReader object and how to use it to return a stream of results from a data source.

Populating a DataSet from a DataAdapter
Describes how to fill a DataSet with tables, columns, and rows by using a DataAdapter.

DataAdapter Parameters
Describes how to use parameters with the command properties of a DataAdapter including how to map the contents of a column in a DataSet to a command parameter.

Adding Existing Constraints to a DataSet
Describes how to add existing constraints to a DataSet.

DataAdapter DataTable and DataColumn Mappings
Describes how to set up DataTableMappings and ColumnMappings for a DataAdapter.

Paging Through a Query Result
Provides an example of viewing the results of a query as pages of data.

Updating Data Sources with DataAdapters
Describes how to use a DataAdapter to resolve changes in a DataSet back to the database.

Handling DataAdapter Events
Describes DataAdapter events and how to use them.

Performing Batch Operations Using DataAdapters
Describes enhancing application performance by reducing the number of round trips to SQL Server when applying updates from the DataSet.

See also