can we have multiple datatables in a datareader ?

Answer Posted / vrsanaidu

Yes, we can have multiple result set means multiple
datatable data in one datareader..., code as below

SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["con"]);
SqlCommand cmd = new SqlCommand("SELECT SiteName FROM
Sites;SELECT SiteCode FROM Sites", con);
cmd.Connection.Open();
SqlDataReader r = cmd.ExecuteReader();
do {
while(r.Read()) {
Response.Write(r.GetString(0) + "<br>");
}
} while (r.NextResult());


r.Close();
con.Close();
cmd = null;
r = null;
con = null;

Is This Answer Correct ?    47 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ado rdo dao in visual basic?

667


What is the difference between linq and ado.net?

515


Which one of the following objects is a high-level abstraction of the connection and command objects in ado.net?

587


Which method is used by command class to execute SQL statements that return single value?

560


What is read only and forward only in ado.net?

519






Explain the namespaces in which .net has the data functionality class.

538


What is oledb driver?

499


Data reader read and forward only, how is it possible to get 2 tables of data at a time?

496


How to add a javaScript function in a datagrid?

571


What is difference between connected and disconnected architecture in ado.net?

589


Explain how to pass multiple tables in datasets simultaneously?

497


Explain sqlconnection object?

536


What is the use of connection object in ado.net?

566


What are the connected and disconnected modes in ado.net?

491


What is variable view?

497