Difference between DataSet and DataReader?

ADO.NET has two major objects for Data Fetching, DataSet and DataReader. What is the Difference between DataSet and DataReader? In which scenario you will prefer DataSet?

Nirmal Sinha
Views: 23292 | Community Opinion: 22

Tags..  ASP.Net Interview  ADO.NET  DataSet  DataReader  .Net Framework

Bookmark this page..



Ask a New Question Go to Home

Community Opinion/Answers
 
Parkash Said..

Comparison of DataSet and DataReader objects (DataSet vs DataReader)

DataSet is a disconnected architecture, while DataReader has live connection while reading data. If we want to cache data and pass to a different tier DataSet forms the best choice and it has decent XML support.

When application needs to access data from more than one table DataSet forms the best choice.

If we need to move back while reading records, datareader does not support this functionality.

One of the biggest drawbacks of DataSet is speed. As DataSet carry considerable overhead because of relations, multiple tables etc speed is slower than DataReader. Always try to use DataReader wherever possible, as it’s meant specially for speed performance.




Virendra I. Yadav Said..

As i am fresher for this question so i do not have any comment




Praveen Said..

This is correct answer in my point view.




kishore Said..

its good but need more information




Amit Said..

Yes




Amit Tiwari From DigiSoft Said..

this is right ans but i think u should provided more information then it




Vivek Jain Said..

i have some more points to include right here:

1- Dataset is heavy weight while DataReader is light weight.
2- Dataset is non persistence while DataReader is persistence.




amit.chandra Said..

Yes, the ans is right.




ebus Said..

good uses full thanks...........




vivek k Said..

DataReader:If you want to display the records from more than one table and the size of the data is more rather than standerd size, then you can go with datareader. Datareader is allow you to read the data but you can not update.
DataSet:If you have a low number of table and data with frequently using then you go for it.




Gaurav Agrawal Said..

For suitable answer go to this URL
http://intquesans.blogspot.com/2011/05/difference-between-dataset-and.html




Gaurav Agrawal Said..

http://intquesans.blogspot.com/2011/05/difference-between-dataset-and.html
this moved to
http://planetofcoders.blogspot.com/2011/06/difference-between-dataset-and.html




santhiya Said..

Data set is read/write access and data reader is read only access




programmings Said..

This is good answer all points are right......i was searching this question long time....i got find more valuable answer from
www.cprogrammings.com of following link........
http://www.cprogrammings.com/result/Difference-between-DataSet-and-DataReader/43.html




Ankit Gupta Said..

1) A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.

2) A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces.
A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine




pavan Said..

1) A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.

2) A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces.
A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine




Mahesh Said..

Re Dont give same answers

MR pavan

1) A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.

2) A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces.
A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine




DhanaLakshmi Said..

1) Dataset is an Disconnected Architecture.
Datareader is an Connected Architecture.

2) Dataset is an Forword also backword to search the
Records in Table.
DataReader is only Forword.

3) Dataset is having the relationship between one or
More Tables in DB.
DataReader is having relationship between only one
table

4) Dataset is Too slow to Access the Records becoz
its an ConnectionLess...
Datareader is Too Fast to Access the Records
becoz its an Connectionoriented....




Vishal Said..

Data reader:-
1)Read only approach
2)Faster access of data
3) forward only approach
4)Used to store single record
5)Bind with single control
6)connected approach
7)It is light weight


Dataset:-
1) Read/write approach
2) slower access in data
3) forward/backward approach
4)Used to store single or multiple table
5)Bind with multiple control
6)Disconnected approach
7)It is heavy weight




Alok Said..

DataReader provides forward-only and read-only access to data, while the DataSet object can hold more than one table (in other words more than one rowset) from the same data source as well as the relationships between them.
Dataset is a disconnected architecture while datareader is connected architecture.
Dataset can persist contents while datareader can not persist contents, they are forward only.




Alok Said..

DataReader
===========
DataReader is like a forward only recordset. It fetches one row at a time so very less network cost compare to DataSet(Fethces all the rows at a time). DataReader is readonly so we can't do any transaction on them. DataReader will be the best choice where we need to show the data to the user which requires no transaction. As DataReader is forward only so we can't fetch data randomly. .NET Data Providers optimizes the datareader to handle huge amount of data.

DataSet
=======
DataSet is an in memory representation of a collection of Database objects including tables of a relational database schemas.
DataSet is always a bulky object that requires a lot of memory space compare to DataReader. We can say that the DataSet is a small database because it stores the schema and data in the application memory area. DataSet fetches all data from the datasource at a time to its memory area. So we can traverse through the object to get the required data like querying database.




gurmeet Said..

DataReader:If you want to display the records from more than one table and the size of the data is more rather than standerd size, then you can go with datareader. Datareader is allow you to read the data but you can not update.
DataSet:If you have a low number of table and data with frequently using then you go for it.






What do you think? Add your opinion/answer
*Name
*your opinion/answer: