J
Jennie.jiang
Hi,
I have a stored procedure which returns two resultsets.
I used SqlDataReader to retrieve the result as following:
SqlConnection con = new SqlConnection(_conString);
SqlCommand cmd = new SqlCommand("MyStoredProcedure", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
//access data
}
if(dr.NextResult())
{
while(dr.Read())
{
//access data
}
}
dr.Close();
con.Close();
The return value of dr.NextResult() is true, but it is empty.
I'm sure there is data in second resultset. Is anything wrong in my code?
Any reply is appretiated.
I have a stored procedure which returns two resultsets.
I used SqlDataReader to retrieve the result as following:
SqlConnection con = new SqlConnection(_conString);
SqlCommand cmd = new SqlCommand("MyStoredProcedure", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
//access data
}
if(dr.NextResult())
{
while(dr.Read())
{
//access data
}
}
dr.Close();
con.Close();
The return value of dr.NextResult() is true, but it is empty.
I'm sure there is data in second resultset. Is anything wrong in my code?
Any reply is appretiated.