Hello everyone,
I am using C# + .Net 3.5 + VSTS 2008 + ADO.Net + SQL Server 2008. And I am sharing one single SQL Connection object (TestDBConnection variable in my below sample) within my application.
The exception I met with is, "There is already an open DataReader associated with this Command which must be closed first.." Any ideas what is wrong?
The patterns within my application which I am using are all like this, i.e. sharing the single db connection object TestDBConnection, and using the single TestDBConnection variable to create command on it and execute store procedure.
using (SqlCommand testCommand = new SqlCommand())
{
testCommand.Connection = TestDBConnection;
testCommand.CommandType = CommandType.StoredProcedure;
testCommand.CommandText = "prc_AddOrderStatus";
testCommand.Parameters.Add("@orderID", SqlDbType.NVarChar).Value = orderID;
testCommand.ExecuteNonQuery();
}
thanks in advance, George