4

I'am using enterprise library data access block in my asp.net application. I want to implement transaction from the Business logic layer, across multiple stored procs. Entlib opens a new connection for database access. Does using Transaction Scope in the following way lead to distributed transaction?

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
    // calling necessary DAL methods
   scope.Complete();
}  

Is there better methods to implement transaction from BLL?

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
developer
  • 41
  • 1
  • 3

1 Answers1

0

If you're talking about SQL Server as the backend, it depends on the server version. Here is a good article: DO.NET and System.Transactions

I quote:

The TransactionScope is smart enough not to create a fully distributed transaction with all of its overhead unless it is necessary. If the resource involved in the transaction is volatile, everything will stay in memory and the Microsoft distributed transaction coordinator (DTC) will not be involved. If the resource is a connection to SQL Server 2005, the DTC will not be involved, and SQL Server 2005 will handle the transaction. This is equivalent to opening an internal SQL transaction. If SQL Server 2000 is used, it will resolve to using a full DTC transaction.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • Good Article. I checked the Transaction.Current. TransactionInformation.DistributedIdentifier within the transaction scope. value is Guid.Empty {00000000-0000-0000-0000-000000000000} So I guess the transaction remains light weight, though i'm doing multiple accesses to the sql server within the same transaction scope. – developer Jan 19 '11 at 04:57