Click to See Complete Forum and Search --> : Simple transaction questions


THY02K
April 12th, 2009, 08:55 PM
hello

QUESTION 1: is it true that .NET framework will automatically enlist help from Distributed Transaction Coordinator?


try {
IDbConnection oConn1 = new SqlConnection("Data Source=Server1;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;");


IDbConnection oConn2 = new SqlConnection("Data Source=Server2;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;");

IDbTransaction oTx1 = oConn1.BeginTransaction();
IDbTransaction oTx2 = oConn2.BeginTransaction();


... oConn1 db access ...
... oConn2 db access ...

oTx2.Commit();
oTx1.Commit();
} catch(Exception ex)
{
oTx2.Rollback();
oTx1.Rollback();
} finally {
...
}


QUESTION 2: There's no "TransactionScopeOption" for IDbTransaction.BeginTransaction?! It's always TransactionScopeOption.New?

QUESTION 3. How can you join transaction without use of TransactionScope? Is there such thing as joining multiple transaction..?


IDbTransaction oTx = oConn1.BeginTransaction();
oConn2.EnlistTransaction(oTx);

oTx.Commit(); // commit commands associated with both connections



Thanks