Answers

Question and Answer:

  Home  ADO.NET

⟩ Can dataReader hold data from multiple tables?

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

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();

 197 views

More Questions for you: