muthukumarm
muthukumarm

Reputation: 197

Regarding ADO.Net

What is the difference between using oledbDataReader and DataAdaptor ?

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

Upvotes: 1

Views: 72

Answers (3)

MatthewMartin
MatthewMartin

Reputation: 33143

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.

Upvotes: 0

RHaguiuda
RHaguiuda

Reputation: 3259

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.

Upvotes: 0

RickNZ
RickNZ

Reputation: 18654

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.

Upvotes: 1

Related Questions