Sunday, March 11, 2012

Is there a difference between Datareader and SqlDatareader or re they the same

R.

"Datareader" is a conceptual thing. There is no class called DataReader in the framework. There is a class called DbDataReader, which every data reader is supposed to inherit from. SqlDataReader thus inherits from DbDataReader, OracleDataReader thus inherits from DbDataReader - - so on so forth.

These are collectively called "DataReader" when talking conceptually. Thus, I opened a DataReader on my SQL databases (which means, I am really working with a SqlDataReader).

Sahil Malik
http://blah.winsmarts.com


Use an SQLDataReader for SQL Server datasources.

Similarly, OleDbDataReader for OleDB datasources such as MS Access and so on...

Though OleDbDataReader's can be used for many datasources, it is always recommended to use the DataReader specifically designed to work with a particular datasource if there is one available. For example, if you are using MySQL, you can download DataReaders specifically designed to work with that datasource.

The same applies to DataAdapters and Command objects, e.g SQLDataAdapter, SQLCommand for working with SQL Server and OleDbDataAdapter, OleDbCommand for working with MS Access.

Steve


Thanks

No comments:

Post a Comment