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