Wednesday, 16 January 2008

Distributed Transactions in MS SQL server 2005

I was developing a .net 2.0 web application with SQL 2000, and used TransactionScope. The machine had the access to database on server through LAN. Everything was working fine, and we had no problem. Then came the upgrade for the SQL server. We decide to roll out 2005 edition of MS SQL and this is where the problems started.
SQL 2005 does not by default allow distributed transactions, so if you are using nested transactions, which could be TransactionScope as well, it will bug up. After a bit of digging up, I found out following steps to get around this bug! So here they are.

First verify the "Distribute Transaction Coordinator" Service is running on both database server computer and client computers

1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not running

If it is running and client application is not on the same computer as the database server, on the computer running database server

1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers > My Computer" (you may need to double click and wait as some nodes need time to expand)
3. Right click on "My Computer", select "Properties"
4. Select "MSDTC" tab
5. Click "Security Configuration"
6. Make sure you check "Network DTC Access", "Allow Remote Client", "Allow Inbound/Outbound", "Enable TIP" (Some option may not be necessary, have a try to get your configuration)
7. The service will restart

On your client computer use the same above procedure to open the "Security Configuration" setting, make sure you check "Network DTC Access", "Allow Inbound/Outbound" option, restart service and computer if necessary.

On you SQL server service manager, click "Service" dropdown, select "Distribute Transaction Coordinator", it should be also running on your server computer.

Powered by ScribeFire.

No comments: