This question is related to my question: http://stackoverflow.com/questions/3072986/sql-server-and-transactionscope-with-msdtc-sporadically-cant-get-connection
I'm doing some transaction programming using the .net TransactionScope
class. If I understand correctly, I can do some SQL operations within a transaction by wrapping the SQL calls inside a using ts as new TransactionScope()
block, or by using new TransactionScope()
and then TransactionScope.Dispose()
at the end.
To commit the transaction, MSDN says to use TransactionScope.Commit()
. Supposing that I want to rollback the transaction under certain circumstances, is it sufficient to simply call TransactionScope.Dispose()
without calling the Commit method first? Is that good practice, or is this supposed to be done some other way?