DAAB v2 and 3 and the DTC

Topics: Data Access Application Block
Feb 8, 2007 at 2:25 PM
The DB is SQL2005.

I was under the impression that in v2 DAAB and TransactionScope didn't work well together. I checked the DTC transaction statistics and the committed transaction count did not go up. I was planning on moving to v3 but now i don't really understand interactions between the System.Transactions classes and entlib v2 and v3 especially in regards to DAAB.

The following is a sample of what i am doing.

Assembly A in a public class:

public Method()
{
MPED.Database db = MPED.DatabaseFactory.CreateDatabase();
using (TransactionScope ts = new TransactionScope())
{
AnotherClass ac = new AnotherClass();
ac.DoSomethingElse();
db.ExecuteNonQuery(SD.CommandType.Text, sql.ToString());
ts.Complete();
}
}

Assembly B:
public class AnotherClass
{
public void DoSomething()
{
MPED.Database db = MPED.DatabaseFactory.CreateDatabase();
using (TransactionScope ts = new TransactionScope())
{
db.ExecuteNonQuery(SD.CommandType.Text, sql.ToString());
ts.Complete();
}
}
}
Feb 8, 2007 at 5:23 PM
OK, I goofed up on that one. I looked at the DTC stats on the wrong computer. For verification though, given the code i posted, version 3 of the DAAB will not create a distributed transaction. Is that correct?
Feb 8, 2007 at 5:42 PM
Correct, with v3 this code should not escalate to DTC.
In v2 the code should work however it will be escalated.

Tom