web dunia
web dunia

Reputation: 9949

Transactionscope not working when two remote sql connections

I am using Two SQL Server connection object in my C# console application project. I need to do this in single transaction So I used Transactionscope (Distributed Transaction)

I am not able to use the connection within the transactionscope It is displaying the error

MSDTC on server is unavailable.

How can I solve.... Both the one sql connection is remote server and another one is local server.

Note:- The msdtc service is already started.

The server started on both the machines. Still I am facing the issue. Do I need to turn off the firewall in my local intranet machines.

Upvotes: 2

Views: 3489

Answers (5)

Niall Connaughton
Niall Connaughton

Reputation: 16117

Just an idea, you've probably tried this already. If you have confirmed that the MSDTC service is running, have you had a look at the event logs on the machines which are running the services? You may find error information from the services there.

Upvotes: 0

Joseph
Joseph

Reputation: 25533

I had the same problem on a project I worked on recently. Unfortunately I did not have the rights to be able to start MSDTC as described in a different answer. If you are in the same situation I would suggest reading the question I posted a while back about this issue.

MSDTC Issue

Upvotes: 1

tvanfosson
tvanfosson

Reputation: 532755

Whenever you do a distributed transaction, the Microsoft Distributed Transaction Coordinator needs to be running on your local machine and on all servers which participate in the transaction. If you have firewalls in place you will also need to make sure that you have limited the ports on which MSDTC communicates and added the appropriate rules to your firewall configuration to allow the connections -- I believe it needs portmapper access as well as the specific port range you've chosen for RPC. There are also various security settings for MSDTC that need to be synchronized that control how authentication is done between the servers.

Here are some links that may be helpful:

  1. MSDTC at MSDN
  2. MSDTC Troubleshooting
  3. MSDTC and Firewall Issues

Upvotes: 2

Marc Gravell
Marc Gravell

Reputation: 1064234

If you are having difficulty getting DTC to play nicely (especially when either a firewall or a SQL cluster are involved) then DTCPing is a great tool (by Microsoft) to identify it. Note that (IIRC) you need to be able to DTCPing in both directions

Upvotes: 2

Mike Chaliy
Mike Chaliy

Reputation: 26708

Start MSDTC Service.

On the command prompt:

net start msdtc

Or from Services MMC. Find "Distributed Transaction Coordinator" and click start.

Upvotes: 2

Related Questions