DataReader Object Overview
As with all connection-specific objects, there is a
DataReader
for every data provider. Here are two
examples:
System.Data.SqlClient.SqlDataReader
provides forward-only, read-only access to a SQL Server database (Version 7.0 or later).System.Data.OleDb.OleDbDataReader
provides forward-only, read-only access to a data source exposed through an OLE DB provider.
Every DataReader
object implements the
System.Data.IDataReader
and the
System.Data.IDataRecord
interfaces. The
IDataReader
interface provides the core
methods shown in Table 5-1, such as Read( )
,
which retrieves a single row from the stream. The
IDataRecord
interface provides the indexer for the
DataReader
and allows you to access the column
values for the current row by column name or ordinal number.
Member |
Description |
Close( ) |
Closes the |
GetSchemaTable( ) |
Retrieves a |
NextResult( ) |
When executing a |
Read( ) |
Loads the next row into the |
The key to understanding the DataReader
is to understand that it loads only a single row into memory at a ...
Get ADO.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.