The big difference is that the DataSet is Disconnected access to the data and the DataReader is a connected access. When you populate a dataset, you get all the rows in the resultset of the query to your dataset. You can then close the database connection but the dataset would have those records for as long as it exists. You can use those results even after the database connection is closed.
The datareader on the other hand is a connected, sequential access to the records. It retrieves data one row at a time. So it keeps the connection to the database open for as long as it is open itself.
If you need to display tabular data in a grid for example you would use dataset(or datatable is even better). If you need to retreive and display one record then you would be best using datareader.
Main Topics
Browse All Topics





by: NikkoliPosted on 2009-03-13 at 21:33:49ID: 23885431
The big difference is that a dataset returns all of the data in your query at once, while a data reader returns any data it gets, as it gets it.
But in reality, they are actually complementary to each other. When you use a DataAdapter, that is actually using DataReader to get the information for that dataset.
If you want a container to carry data round from one object or method to another, the dataset is perfect for this, but if you want to work with the data immediately, you can get a performance gain from using the DataReader Directly.
using both is as follows:
Select allOpen in new window