Name
IDataReader
Synopsis
The IDataReader
interface is implemented by all
data readers. A data reader provides a way to read a command-only
stream of data from a data source. You can’t create
a data reader directly. Instead, an open
IDataReader
instance is returned from the
IDbCommand.ExecuteReader( )
method. You can then
use the Read( )
method to move from one row to the
next. The Read( )
method returns
true
if it can successfully read a row or
false
if there are no more rows remaining, and it
has moved beyond the bounds of the result set. There is no way to
move backward. When it is first created, the
IDataReader
doesn’t yet point to
a row. You must call Read( )
to move to the first
row before you attempt to read any information. You can use
NextResult( )
to move to the next result set if
you are using a command or stored procedure that returns multiple
result sets.
You retrieve data from a row (the row the
IDataReader
is currently positioned on) by column
name or index. The IDataReader
acquires this
functionality through the IDataRecord
interface,
which it extends.
public interface IDataReader : IDisposable, IDataRecord { // Public Instance Properties public int Depth{get; } public bool IsClosed{get; } public int RecordsAffected{get; } // Public Instance Methods public void Close( ); public DataTable GetSchemaTable( ); public bool NextResult( ); public bool Read( ); }
Implemented By
System.Data.OleDb.OleDbDataReader
, System.Data.OracleClient.OracleDataReader
, System.Data.SqlClient.SqlDataReader ...
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.