0
 TransactionOptions options = new TransactionOptions();
 options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
 options.Timeout = new TimeSpan(0, 5, 0);
 using (TransactionScope scope = new  TransactionScope(TransactionScopeOption.Required, options))                    
 {
     try
     {
           Update to Database One;
           Update to Database Two;
           scope.Complete();    
     }
     catch (Exception ex)
     {
         scope.Dispose();
         throw;                            
     }
}

I have two SQL updates that I need to do in .NET transaction. The above code is giving me the error:

"Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool."

DTC is enabled on both the servers where the databases are installed. Please guide me in the right direction.

Backs
  • 24,430
  • 5
  • 58
  • 85
Richard
  • 381
  • 2
  • 4
  • 22
  • Why don't you use stored procedure to run 2 queries then execute it in your code? – dan Aug 06 '15 at 01:19
  • Is MSDTC enabled on server where code is running? – Backs Aug 06 '15 at 01:28
  • @Dan it is located in two different servers and I cannot have a transaction and use linked servers – Richard Aug 06 '15 at 02:24
  • @Backs: I will look into that and see if it is enabled. thank you for pointing out. – Richard Aug 06 '15 at 02:25
  • possible duplicate of [How do I enable MSDTC on SQL Server?](http://stackoverflow.com/questions/7694/how-do-i-enable-msdtc-on-sql-server) – Will Aug 06 '15 at 11:39
  • 2
    FYI, `TransactionScope`, if used with `using`, will automatically Dispose and rollback if things fail. You don't need the Try/Catch as shown in your example, just the 2 updates and the `Complete`. – Will Aug 06 '15 at 11:42

0 Answers0