Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlDataReader problem with multiple resultsets

Status
Not open for further replies.

Husein

Programmer
Jan 29, 2000
25
JO
Hi,

I have a multiple resultset returned by the stored procedure (4 select statements returning different scalar values).

When I call SqlCommand's ExecuteReader on the following piece of code:

cn = new System.Data.SqlClient.SqlConnection(ConnectionString);

cn.Open();

SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "spResSupervisorSwitchboard";
cmd.CommandType = CommandType.StoredProcedure;

SqlDataReader rdr = cmd.ExecuteReader();

while(rdr.Read()) // System.InvalidOperationException
{
lblWaitingFirstEntry.Text = rdr[0].ToString();
}

rdr.NextResult();

The connection is opened fine, the stored procedure name is correct, stored procedure returns values when executed in SQL Query Analyzer.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top