C
ChrisB
Hello All:
I am attempting to execute two statements as part of a single transaction
using the Microsoft data access application block. The code, which is
similar to what follows, returns this message when it attempts to execute
the second "SqlHelper.ExecuteReader" statement:
"The SqlCommand is currently busy Open, Fetching"
I would greatly appreciate any insight!
Thanks,
Chris
----------------------------------------------------------------------------
-
SqlConnection sqlConnection = new SqlConnection(DB("SPMS"));
sqlConnection.Open();
SqlTransaction sqlTransaction =
sqlConnection.BeginTransaction(IsolationLevel.Serializable);
try
{
// Set parameters
// Insert consumer
SqlDataReader sqlDataReader =
SqlHelper.ExecuteReader(sqlTransaction, CommandType.StoredProcedure,
"ConsumerAdd", consumerParameters));
safeDataReader.Close();
// Insert consumer history
SqlDataReader sqlDataReaderHistory =
SqlHelper.ExecuteReader(sqlTransaction,CommandType.StoredProcedure,"Consumer
HistoryAdd",consumerParameters));
sqlTransaction.Commit();
}
catch(Exception Exception)
{
sqlTransaction.Rollback();
throw Exception;
}
finally
{
sqlConnection.Close();
}
I am attempting to execute two statements as part of a single transaction
using the Microsoft data access application block. The code, which is
similar to what follows, returns this message when it attempts to execute
the second "SqlHelper.ExecuteReader" statement:
"The SqlCommand is currently busy Open, Fetching"
I would greatly appreciate any insight!
Thanks,
Chris
----------------------------------------------------------------------------
-
SqlConnection sqlConnection = new SqlConnection(DB("SPMS"));
sqlConnection.Open();
SqlTransaction sqlTransaction =
sqlConnection.BeginTransaction(IsolationLevel.Serializable);
try
{
// Set parameters
// Insert consumer
SqlDataReader sqlDataReader =
SqlHelper.ExecuteReader(sqlTransaction, CommandType.StoredProcedure,
"ConsumerAdd", consumerParameters));
safeDataReader.Close();
// Insert consumer history
SqlDataReader sqlDataReaderHistory =
SqlHelper.ExecuteReader(sqlTransaction,CommandType.StoredProcedure,"Consumer
HistoryAdd",consumerParameters));
sqlTransaction.Commit();
}
catch(Exception Exception)
{
sqlTransaction.Rollback();
throw Exception;
}
finally
{
sqlConnection.Close();
}