This is a rewrite of a post to microsoft.public.dotnet.framework.adonet.
I'm having a discussion with my team leader concerning the use of
SqlTransactions.
We work on an ASP.Net 1.1 website. Up until now we've been using
ADO.Net SqlTransactions in our business logic layer to combine several data access layer method calls into one coherent, atomic action.
I am in favor of this approach as it supports isolating the business logic from the database and provides for greater code readability.
My team leader diagrees - he thinks that we need to get rid of all ADO.Net SqlTransactions and instead guarantee atomicity by combining data operations inside stored procedures with transactions.
The reasons why he says SqlTransactions are bad are:
1. If one of the running threads in the IIS just dies all of a sudden, it would leave a transaction open and stuck, putting strain on the DB and risking deadlocks.
2. The DBA won't be able to properly debug the SQL Server whenever deadlocks and critical loads are encountered. Because transactions are opened from a place outside of the DBA's scope he will have no way of
knowing how or why certain statements and stored procedures might be executing together or locking each other.
Would you agree with my team lead? Do reason 1 and/or reason 2 justify moving some of our business logic into our DB? If not, does anyone have contradictory examples or links?
I'm calling on whoever is reading this to share their knowledge as I find that I do not know ADO.Net SqlTransaction well enough at this time.