What is the difference between DataSet and DataReader?

What is the difference between DataSet and DataReader in Asp.net with Example…

Google sometimes has the answer or at least can point you to it.

You can also use MSDN to find such answers.

The DataSet actually uses a DataReader to populate itself. A DataReader is a lean, mean access method that returns results as soon as they’re available, rather than waiting for the whole of the query to be populated into a DataSet. This can boost your application performance quite dramatically, and, once you get used to the methodology, can be quite elegant in itself.

DataReader is just reader that reads the resultant data from a query and fills the DATASET. It is just only one pass.

DATASET mimics the resultant record set, which we can iterate and obtain the data.

Hello

From the sitepoint BYO ASP.Net ebook:

“The two main points you need to keep in mind about SqlDataReader are:
■ It represents the fastest method available to read data from the data source.
■ It allows read-only, forward-only access to data.”

DataSets are read/write and you can also move forwards and backwards through them

To me the trade off is performance vs. updatablity.

Hello,

Data Set is a service without connection and Data Reader is a connection oriented service.

Data Set is used to store the data, it contains collections of Data Table.Data Reader is used to connect to the database for retrieving data.

I hope you got your answer

Dataset is a form of disconnected architecture. A whole database can be retrieved using dataset and store it in local memory. Dataset contains tables of data. While data reader is used for reading a particular value or a single row.

Data reader

  1. It is a read only and forward only data.
  2. U can access one table at time.
  3. It can’t persist the data.
  4. It is comes under connected architecture.
  5. One of the most advantage is it is much faster than data
    adapter

Data set:

  1. It is defined with multiple tables.
  2. It can persist the data.
  3. It is a relational data cache hosted in application
    domain during execution.
  4. It is a disconnected architecture.
  5. It can’t defined with out data adapter.

dataset is actually reflection of database data in memory. you edit it and save it and it will save in db. where as data reader is readonly data dont give you facility of edit thats why it is fast

That’s enough of what, anyone have an example?