O'Reilly logo

Essential ADO.NET by Bob Beauchemin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required