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