Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:

I can see many threads around DataSet and Datareader. It all says,

Datareader is faster, read/forward only , connected architecture etc.

where as Dataset is disconnected model so user can work offline and update the Database later on, thus saving connection resource to remain open for longer.

I do understand above points.

But I am quite confused with respect to below points:

1) I need to just show some records to my grid in UI (which i can bind with DataSet or Collection list)

In the DAL layer i can use DataReader to populate my list, send it to client and bind with Grid. Or I could have used DataAdapter to fill dataset and send that Dataset to client to bind with Grid.

So in above scenario it means i discussed both approach (connected and disconneted)..right?

My question is: which approcah is better ?

If Answer is "DataReader", since DataRedaer is faster and we dont need any DML operations and just need to present data, than

Anyway i need to have data popuated in either list or dataset from reader one by one, so why not DataAdapter.Fill() to get Dataset directly ?

Second qusetion, how one can perform DML operation in connected mode ? Data reader is read/forward only..right?

Please help me overcoming this confusion.

i think some practical example which to diffrenciate btwn two would be helpful.



hey! Rahul lets understand abouot nature of DataReader and DataSet. as you know DataReader is used to employ directly connected to database system where as Dataset is generally used to employ disconnected architecture of database System.
if we will look for local storage system then we will found that Dataset is used to reads data from database and stores in local system where as for DataReader there is no Local storage is required.
so before choosing one of them while performing then you should focus on above points including you can select DataSet as a option when you are going for more number of operations(updates, inserts and deletes) on database and updates done in batch wise, then dataset will be best option. Use Dataset, if you are going to implement sites, which are no need of changes on every client clicks, such as "Carting in shoping mall sites", "display information in websites from database". where as select DataReader when you are going to fewer operations and directly implementation of queires on database, the datareader is best option. Use DataReader, if you are going to implement "Booking a berth in Railways", "display current price in Stock Market".

so its not called that DataReader is best than DataSet.
the outcome depends upon the Performance. so Choose Dataset or DataReader according to situation, purpose and uses of database display.

Answer of your Second Question which is related to DML operation in Connected Environment.
you are free to use ExecuteNonQuery() function which is used to execute SQL statement against connection and returns number of row affected.
Share this answer
Hope DataReader Vs DataSet[^] might help you.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900