Why would DTC be involved on single DB transaction?

Why would DTC be involved on single DB transaction?

Old forum URL: forums.lhotka.net/forums/t/2345.aspx


swegele posted on Wednesday, February 14, 2007

I thought Rocky said using TransactionScope  option  meant ADO.NET transactions when only hitting one database...so why do I have to mess with DTC Service configuration to avoid that error about remote transactions?

Why would I want my users having to go mess with DTC stuff?  I barely understand it how could I expect a user of COTS to understand what needs to be changed on their XPSP2 box?!!

Is there something I am missing?  Any other COTS developers out there that actually use System.Transactions in a 2 tier setting?

Sean

RockfordLhotka replied on Wednesday, February 14, 2007

This has come up on the forum before as well. The issue is that the docs and Microsoft info about System.Transactions is simply wrong. I've even talked to people on the data team at Microsoft and they think the docs are right. But they are not Sad [:(]

Opening multiple connections to the same database, with the same connection string, is still viewed as mutliple database connections by System.Transactions. This causes System.Transactions to enlist the DTC.

To avoid this you need to open ONE database connection and reuse it through your entire object graph. This is one of the reasons I added LocalContext in version 2.1, to make this easier to manage.

swegele replied on Wednesday, February 14, 2007

Cheers to MS!

Hmmm interesting....I use the local context solution you recommended and I get the DTC enlistment when I open my first connection.

I am thinking the problem is LLBLGen...my DAL.  I store their DataAcessAdapter in LocalContext.   I merely call:

adapter.OpenConnection

Whammo! I bet it is doing something under the covers to trigger this behavior.

I am thinking I might cut and run and just use the built in LLBLGen transaction features.

Sean

 

RockfordLhotka replied on Wednesday, February 14, 2007

Perhaps they are “optimizing” the data access by opening/closing connections on your behalf. Which normally would be good I’m sure, but in this case could be causing you problems.

 

Rocky

swegele replied on Wednesday, February 14, 2007

Ahhhh I think I see...

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5220

The last couple messages seem to point out the issue:

Well, you can use a TransactionScope with SQL Server 2000, however, it will be a DTC transaction automatically. SQL Server 2000 doesn't support light weight transactions, as they call it.

BOb

Sean

Copyright (c) Marimer LLC