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
How to maintain the relation between two tables in ADO.NET?
What is the role of the dataset object in ado.net?
Is it possible to edit data in Repeater control?
What is ole2 format?
How to read data with the sqldatareader ?
What are the steps you will take to improve performance? Will you use dataset or datareader?
oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?
What is data reader in ado.net?
What are good ado.net object to replace to ado recordset object.
How to identify the controls which can be used for binding data?
Which method is used by command class to execute SQL statements that return single value?
What is Serialization in .NET? what are the types of Serialization?
I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?
How to aggregating data across related tables?
What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?