CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Threaded View

  1. #1
    Join Date
    Feb 2001
    Posts
    872

    Simple transaction questions

    hello

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

    Code:
    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..?
    Code:
    IDbTransaction oTx = oConn1.BeginTransaction();
    oConn2.EnlistTransaction(oTx);
    
    oTx.Commit(); // commit commands associated with both connections

    Thanks
    Last edited by THY02K; April 12th, 2009 at 09:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured