DataReader Object Overview
As with all connection-specific objects, there is a
DataReader for every data provider. Here are two
examples:
System.Data.SqlClient.SqlDataReaderprovides forward-only, read-only access to a SQL Server database (Version 7.0 or later).System.Data.OleDb.OleDbDataReaderprovides 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access