Reputation: 2526
My question is related to this topic TransactonScope.
I have a web server and a database server and a remote database server.
I want to have a distributed transaction between local and remote server. I configured MSDTC for database servers and I can have a distributed transaction in Database servers with linked server.
but when I use Transaction scope in system.transactions
name space I encounter following error when I Just open the second connection (Remote Connection).
error:
The transaction has already been implicitly or explicitly committed or aborted.
simplified code:
using (TransactionScope tscope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
//open connection db 1
//insert into db1
//open connection db2 (Remote databse) -- the problem is here
//insert into db2
tscope.Complete();
}
Upvotes: 0
Views: 930
Reputation: 4665
You should enable it since the runtime WHEN NECESSARY will escalate the transaction to use the Distributed Transaction Coordinator
Upvotes: 1