0

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();
}
Community
  • 1
  • 1
Raymond Morphy
  • 2,464
  • 9
  • 51
  • 93

1 Answers1

1

You should enable it since the runtime WHEN NECESSARY will escalate the transaction to use the Distributed Transaction Coordinator

John Gathogo
  • 4,495
  • 3
  • 32
  • 48
  • How to enable it Run time? Please explain me more – Raymond Morphy Nov 03 '11 at 05:35
  • Enable the MSDTC service, if you have not enabled it already. Also check that your network security settings are set up properly. Look at the section [Set the appropriate MSDTC Security Configuration options on Windows Server 2003 SP1, Windows XP SP2, Windows Server 2008, and Windows Vista] on this link: http://msdn.microsoft.com/en-us/library/aa561924(v=bts.20).aspx – John Gathogo Nov 03 '11 at 05:41
  • Should I enable MSDTC on My web server too? I enabled it for Local and remote Database servers? – Raymond Morphy Nov 03 '11 at 05:45
  • I can ping remote database server with DNS Name and remote server can ping My local database server with Name too. – Raymond Morphy Nov 03 '11 at 05:58