views:

188

answers:

1

We are having problems on one machine, with the error message:

"MSDTC on server XXX is unavailable."

The code is using a TransactionScope to wrap some LingToSql database code; there is also some raw Ado.net inside of the transaction.

As only a single sql database (2005) is being accessed, why is a distributed transaction being used at all?

(I don’t wish to know how to enable MSDTC, as the code needs to work on the server with their current setup)

+5  A: 

This almost always happens when your transaction uses more than one database connection. So, let's say you are updating two tables. You might update the first table using one connection but update the second table using a different second connection. This will cause the transaction to be escalated to MSDTC, even using a TransactionScope object.

The way we got around this is when performing transactions, we use a single database context object for all our writes. This eliminated the escalation. Since doing this, we've never had the MSDTC message appear.

Randy

Randy Minder
...single datacontext won't do it alone, you also need to supply a connection to the DCs constructor to ensure it uses a single connection....
KristoferA - Huagati.com