Opinions sought: Transactions

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
Microsoft advocate using transaction server with a block of code like this:

VB.NET:
Using ts as New System.Transactions.TransactionScope()

... multiple tableadapter calls to update

End Using

This is occasionally quite slow, though I think it MAY have the advantage of rolling back any client side changes if the transaction fails (i.e. you get 50% through your inserts then they fail, it might revert all your rows that up to now have been AcceptChanges()d so that they can participate again)

Does anyone else perform database transactions other ways?

TableAdapters, ingeniously designed as they are, actually do not fiddle with the state of a connection if it is already open when they come to use it. THis means we can open our first conenction manually, and start a transaction on it, then pass that connection and also transaction to every other tableadapter we wish to use in the same transaction. Does anyone do this? How did it work out for you?
 
Might it help (and I'm not sure this is possible) to gather info/stats while running, then examine stats from time periods when transactions are slow - and maybe point to a cause? Resource contention comes to mind...
 
My current work project is an EDI import application. I've been using transactions for DB interactions simply because of the rollback capabilities. Due to the nature of the rest of the application, partial inserts would be detrimental. Usually works quite well: when something dies during the update process, nothing is written to the DB, all tables are rolled back.
 
Please note, i'm not asking what a transaction is, or whether I should use one. I'm asking how other people choose to implelemnt them in .NET 2
 
Back
Top