none
TransactionAbortedException: The transaction has aborted. ---> System.InvalidOperationException: The requested operation cannot be completed because the connection has been broken

    Question

  • Hi,
    I occasionally get the above exception when calling txnScope.Complete(). I have followed the .Net example for implementing the TransactionScope.

    Is it correct to first create the transaction scope and then create the SqlConnections inside it?

    Why does the connection get broken?

    using (TransactionScope scope = new TransactionScope())
    {
       using (SqlConnection connection1 = new SqlConnection(connectString1))
       {
          // TransactionScope as a lightweight transaction.
          connection1.Open();
          ...
          
       }
          
       using (SqlConnection connection2 = new SqlConnection(connectString2))
       {
          // The transaction is escalated to a full distributed
          // transaction when connection2 is opened.
          connection2.Open();
          ...
          
       }
       scope.Complete();
    }
    Thanks
    Martin
    • Moved by KJian_ Friday, September 04, 2009 7:48 AM (From:.NET Framework inside SQL Server)
    Tuesday, September 01, 2009 6:36 PM