ziwez0
asked on
SQL Transaction Statement
Hi,
Im trying to get my headaround the sqltransaction class.
I can do the simple statement like (see below).
//Execute Stage 1
SqlTransaction trans;
using (trans = con.BeginTransaction())
{
try
{
string strInsertData = " INSERT INTO BLAH BLAH BLAH WHERE BLAH =@BLAH";
SqlCommand cmd_ExecuteInsert = new SqlCommand();
// MORE CODE
cmd_ExecuteInsert_RMA.Tran saction = trans;
trans.Commit();
}
catch
{
trans.Rollback();
}
//Execute Stage 2
// OK now I want to Update another database, but if it fails I need to Roll back stage 1
// Can someone provide an example on how to do this please
Im trying to get my headaround the sqltransaction class.
I can do the simple statement like (see below).
//Execute Stage 1
SqlTransaction trans;
using (trans = con.BeginTransaction())
{
try
{
string strInsertData = " INSERT INTO BLAH BLAH BLAH WHERE BLAH =@BLAH";
SqlCommand cmd_ExecuteInsert = new SqlCommand();
// MORE CODE
cmd_ExecuteInsert_RMA.Tran
trans.Commit();
}
catch
{
trans.Rollback();
}
//Execute Stage 2
// OK now I want to Update another database, but if it fails I need to Roll back stage 1
// Can someone provide an example on how to do this please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.