What is the difference between a Dataset and DataReader?
Can dataReader hold data from multiple tables?

Answers were Sorted based on User's Feedback



What is the difference between a Dataset and DataReader? Can dataReader hold data from multiple tab..

Answer / karna

data set a collection of datatables and we can edit the
data in the datatables and the same can be persisted to
databae using adapter in the disconnected maner by using
commandbuilder or insert,update,select command.

datareader is just the container for data,its readonly and
forwardonly curosr.this follows connected architecture,that
means when we are reading data from datareader at that time
connection should be kept open.

data reader can hold data from multiple tables and
datareader can hold more than one table.

Example:

string query="select * from employee;select * from student";
sqlcommand cmd=new sqlcommand(query,connection);
sqldatareader dr=cmd.executeReader();
if(dr.hasrows)
{
dr.read();
gridview1.DataSource=dr;
gridview1.Databind();
if(dr.nextresult)
{
gridview2.datasource=dr;
gridview2.databind();
}
}
dr'colse();
connection.close();

if anybody have any doubts,mail to me on karun84@gmail.com

Is This Answer Correct ?    14 Yes 5 No

What is the difference between a Dataset and DataReader? Can dataReader hold data from multiple tab..

Answer / naresh

Data reader:
1. It is a read only and forward only data access to data.
2. You 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 can access multiple tables at a time.
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 define with out data adapter.


Yes.dataReader hold data from multiple tables. The SELECT
statement may have columns that belong to one or more
"tables in the database". By example using a JOIN
or something similar.

Is This Answer Correct ?    1 Yes 2 No

What is the difference between a Dataset and DataReader? Can dataReader hold data from multiple tab..

Answer / sandyni

DataSet is a disconnected object and holds the data from
datastore. It can hold the data of more than one table.

where as dataReader is connected architecture which can
rbe used to read the data from the dataset in forward only
fashion. DataReader cannot hold multiple tables of data.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More ADO.NET Interview Questions

What is the procedure to call a Stored Procedure of Back End in ADO (ActiveX Data Object) and RDO (Remote Data Objects)?

0 Answers   CGI,


What is the difference between dataset and datatable?

0 Answers  


Why is stored procedure used in ado.net?

0 Answers  


Being fresher How would i answer to the question that what is your salary exception?

4 Answers  


FetCh Records No 5 to 10 From Dataset

4 Answers  






What do you mean by performing asynchronous operation using command object?

0 Answers  


Define isolation?

0 Answers  


Explain acid properties?

4 Answers  


How would you connect to database using .NET?

0 Answers  


How to create data relations?

0 Answers  


IF we have lot of records in Database. How we can handle them?

5 Answers   Honeywell,


what is Execute NOn Query?

29 Answers   Infosys, Protech, Sars Systems, SwanSoft Technologies,


Categories