Thursday, July 8, 2010
On writing an .NET application with multiple LINQ insert/update statements TransactionScope is useful.
Letz say we are inserting EmployeeInfo table, then EmployeeSalaray table, followed by EmployeeAttendance table.
When the application completes all work it wants to perform in a transaction, Complete method informs transaction manager that it is acceptable to commit the transaction. Failing to call this method aborts the transaction. Isn't it cool?
But, I got an error '[System.Transactions.TransactionManagerCommunicationException] during TransactionScope execution. On analysis, it has been found Network access for Distributed Transaction Manager (MSDTC) has been disabled by default in XP. MSDTC is a transaction manager which permits client applications to include several different sources of data in one transaction, and which then coordinates committing the distributed transaction across all the servers that are enlisted in the transaction.
To resolve this issue, MSDTC is enabled via 'Control Panel->Administrative Tools->ComponentServices->MyComputer' MSDTC properties. You need to click on Security Configuration button under Transaction Configuration panel. In that section, enable 'Network DTC Access' After this setup, my application runs smoothly and TransactionScope is successful.