When my C#.net application updates records in more than one table, I use transactions so if anything should fail during the transaction I can rollback.
Which one is a better practice?
-Use stored procedure with BEGIN TRANSACTION/ROLLBACK/COMMIT TRANSACTION; -Use TransactionScope in the application as below:
using (TransactionScope ts = new TransactionScope()) { }
This isn’t a business logic issue, it’s a data integrity issue and I feel that is ok to do in the stored procedure. I like to keep transaction logic as close to the operations as possible to shorten their duration.