views:

22

answers:

3
+1  Q: 

Regarding ADO.Net

What is the difference between using oledbDataReader and DataAdaptor ?

Which one is best to use ? for fetching data from db...

+1  A: 

You can use ADO.NET either in a generic style (using the interface definitions), which makes it easier to port your app to a new database, or in a DB-specific form.

If you're using SQL Server and don't plan to switch, then it's usually better to stick with the SqlClient classes, such as SqlDataAdapter and SqlDataReader.

To fetch from a DB, the best option depends in part on where you want to put the data after you read it. SqlDataAdapter.Fill() is good for DataSets or DataTables; SqlDataReader is good for custom classes. SqlDataReader is probably a bit faster, but it also does less for you.

RickNZ
can u elaborate little bit more on that you mentioned "SqlDataReader is good for custom classes.".
muthukumarm
For example, say that you have a class where you would like to have one instance of the class represent one row from the response to a query. With `SqlDataReader` you can quickly read a row, and then use the results to populate a new instance of your class.
RickNZ
A: 

I belive there`s some kind of confusion in this question.

DataReader is used for read-only stream of data, while DataAdapters are used to read and write data using DataSets.

Both can be used with OleDB, SQL or Oracle.

RHaguiuda
A: 

There are a long list of disadvantages of using DataSets. Unless you have a specific reason for using DataSets (which go hand in hand with DataAdapters), default to using DataReaders.

Hanselman has a recent good post comparing four types of data access including DataSets and DataReaders.

MatthewMartin