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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an ado connection?

706


Which is the feature of ado.net?

725


Why is ADO.NET serialization slower than ADO ?

794


What is dataadapter in ado.net?

684


How can I retrieve two tables of data at a time by using data reader?

709


What are the major challenges in accessing data from a database?

738


What is an ADO.Net?

750


What is data relation in ado.net?

711


Can we connect two dataadapters to same data source using single connection at same time?

733


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

735


What is ado.net full form?

733


What is connected architecture in ado.net?

688


How can we load multiple tables in a dataset?

766


What are ado.net objects?

712


What is ado control?

695