sql server - Rollback at stored procedure vs rollback at C# code -



sql server - Rollback at stored procedure vs rollback at C# code -

i have procedure proc1 calls procedure proc2, , both "begin transction" if error @ sec procedure, rollback both procedures. ok!

but within c# code, have this

... dbcommand.transaction.commit(); dbcnn.close(); } grab (exception ex) { if (dbcommand.transaction != null) **dbcommand.transaction.rollback();** if (dbcnn.state == connectionstate.open) dbcnn.close(); throw ex; }

does "dbcommand.transaction.rollback();" knows transaction talking about? , if have 2 transactions ate same procedure, without label, problem c# rollback right transaction?

does "dbcommand.transaction.rollback();" knows transaction talking about?

no. not care. rolls transaction wrapping on connection level. within part of transaction.

and if have 2 transactions ate same procedure, without label, problem c# rollback right transaction?

you can not have 2 transactions. transactions form hierarchy. code above rolls whole top level connection level transaction. every other transaction open in sstored procedure part of transaction.

c# sql-server stored-procedures transactions

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -