Hi
Can someone shed light on what is happening behind the scenes with the SQL Lightweight transaction manager when multiple connections are opened to the same DB?
With the below code, we verified that MSDTC is indeed not required when opening 'multiple connections' to the same database.
In the first scenario (where Txn1 and Txn2 use EntLib 4.1 to open a connection to the same DB and call different SPROCS):
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
DAL1.Txn1();
DAL2.Txn2();
ts.Complete();
}
Tracing this from profiler revealed that the same connection SPID was used for Txn1 and Txn2. OK, fine, after Txn1() was called, the SPID may have been released back into the pool and Txn2() just happened to re-use it.
However, when repeating this experiment and this time holding the connections open:
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
Database db1 = DatabaseFactory.CreateDatabase("db1");
DAL1.Txn1OnCon(db1);
Database db2 = DatabaseFactory.CreateDatabase("db1");
DAL2.Txn2OnCon(db2);
ts.Complete();
}
Viewing this from Profiler indicated that the 2 transactions were STILL using the same SPID. What have I missed?
Thanks!