> In Transaction environments it is often a good idea to catch 
> all exceptions to rollback the transaction , id hate to miss 
> a transaction because I forgot a certain type of exception 
> that may occur such as Argument out of range ,arithmetic 
> errors etc  .  In .NET 2.0 this is handled better with 
> Transaction Scope . 

Since you're not actually interested in doing anything
with the exception, you just need to have a finally
clause that abandons incomplete transactions. Looking
at SqlTransaction, this requires explicit action to
commit it, and supports IDisposable, making it a candidate
for using (SqlTransaction trans= new SqlTransaction()),
with trans.Commit() being the last statement in the block.

No need to trap the exceptions that get thrown, just that
you're leaving scope without having completed the block.

I read somewhere that try/finally blocks should outnumber
try/catch blocks 10:1
http://www.artima.com/intv/solid2.html

John

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to