8.7. Implementing the DataReader Class

DataReader classes do not have a public constructor. They must implement both the IDataReader and the IDataRecord interface. The DataReader class allows the user to read in a forward-only, row-at-a-time fashion and get typed data or generic types from the columns in each row. Listing 8-5 shows IDataReader and IDataRecord.

Listing 8-5. IDataReader and IDataRecord
 public interface IDataReader { // IDataReader methods public DataTable GetSchemaTable(); public void Close(); public bool NextResult(); public bool Read(); // IDataReader properties public int Depth public bool IsClosed public int RecordsAffected } public interface IDataRecord { // IDataRecord methods public bool GetBoolean(int i); public byte GetByte(int ...

Get Essential ADO.NET 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.