Επεξεργασία

Κοινή χρήση μέσω


DataAdapters and DataReaders

Applies to: .NET Framework .NET .NET Standard

Download ADO.NET

You can use the Microsoft SqlClient Data Provider for SQL Server 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 Microsoft SqlClient Data Provider for SQL Server to connect to a data source, and it uses Command objects to retrieve data from and resolve changes to the data source.

.NET has a DbDataReader and a DbDataAdapter object: the Microsoft SqlClient Data Provider for SQL Server includes a SqlDataReader and a SqlDataAdapter object.

In this section

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

Populate 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.

Add 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.

Update data sources with DataAdapters
Describes how to use a DataAdapter to resolve changes in a DataSet back to the database.

Handle DataAdapter events
Describes DataAdapter events and how to use them.

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