Possible Duplicate:
ExecuteNonQuery requires the command to have a transaction error in my code
strSQL = "insert into............";
SqlTransaction objSqlTransaction = Master.objSqlDbComm.SqlConnectionObject.BeginTransaction();
try
{
Master.objSqlDbComm.ExecuteNonQuery(strSQL);
objSqlTransaction.Commit();
}
catch(Exception)
{
objSqlTransaction.Rollback();
}
finally
{
objSqlTransaction.Dispose();
}
When I use above code getting error
ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.