21.1 Comments/Troubleshooting

Most ADO.NET providers include a strongly typed DataReader . Every DataReader implements two interfaces: IDataReader (which defines the core reader functionality) and IDataRecord (which allows you to access the current record values). Because IDataReader extends IDataRecord, you can use the IDataReader to access all the IDataRecord and IDataReader functionality when writing provider-agnostic data access code.

Strongly typed DataReader objects typically add type-safe methods that allow you to retrieve column values as database-specific data types. Some DataReader classes for ADO.NET providers are shown in Table 21-1.

Table 21-1. Provider-specific DataReader classes

Class

Data source

System.Data.SqlClient.SqlDataReader

SQL Server

System.Data.OleDb.OleDbDataReader

An OLE DB provider

System.Data.Odbc.OdbcDataReader

An ODBC driver

System.Data.OleDb.OracleDataReader

Oracle



    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference