G
Guest
hi friends
I am developing web application in .NET using c#. I encounter a problem in binding the results to the datagrid. I have a storeprocedure that produce 2 results set. I need to read the results and bind it in a datagrid control. But i am able to bind only one result set eventhough i am using the datareader.next result(); Can any one of you help me? My code follows here
SqlCommand cmd1 = new SqlCommand("Testpaper_DHistory",conn);
cmd1.CommandType=System.Data.CommandType.StoredProcedure;
SqlParameter myparam = cmd1.Parameters.Add(new SqlParameter("@nric",SqlDbType.VarChar,20));
myparam.Value = Session["userid"].ToString();
SqlDataReader myreader = cmd1.ExecuteReader();
do
{
Grid1.DataSource=myreader;
Grid1.DataBind();
}
while (myreader.NextResult());
myreader.Close();
conn.Close();
Even I tried Grid1.Datasource = cmd1.ExecuteReader(); It is also not working.
I am developing web application in .NET using c#. I encounter a problem in binding the results to the datagrid. I have a storeprocedure that produce 2 results set. I need to read the results and bind it in a datagrid control. But i am able to bind only one result set eventhough i am using the datareader.next result(); Can any one of you help me? My code follows here
SqlCommand cmd1 = new SqlCommand("Testpaper_DHistory",conn);
cmd1.CommandType=System.Data.CommandType.StoredProcedure;
SqlParameter myparam = cmd1.Parameters.Add(new SqlParameter("@nric",SqlDbType.VarChar,20));
myparam.Value = Session["userid"].ToString();
SqlDataReader myreader = cmd1.ExecuteReader();
do
{
Grid1.DataSource=myreader;
Grid1.DataBind();
}
while (myreader.NextResult());
myreader.Close();
conn.Close();
Even I tried Grid1.Datasource = cmd1.ExecuteReader(); It is also not working.