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

Explain advantages of ado.net?

550


how can implement dropdownlist in particular of dataset when try to update?

2300


What is the return type of executescalar?

489


What is difference between ado and other data object?

461


Why do we use sqldataadapter?

475






What is ole db and odbc?

513


What is ado.net object model?

508


What DataReader class do in ADO.NET ?

576


Explain the different row versions available in table?

538


differance between ADO vs ADO.Net?

541


Why ca not we use multiple inheritance and garbage collector paralelly in .net?

546


How will you differentiate between ADO (ActiveX Data Object) and RDO (Remote Data Objects)?

574


What are the pre-requisites for connection pooling?

529


What is microsoft ado?

507


Give an example that shows how to execute a stored procedure in ado.net?

559