How can I trap errors by using "Using Statement".
I would like to use System.Transactions namespace to commit (if no errors) and rollback transactions (if there are errors).
What is the best way to do this?
Sample 1.
button save click:
or
Sample 2.
button save click:
I would like to use System.Transactions namespace to commit (if no errors) and rollback transactions (if there are errors).
What is the best way to do this?
Sample 1.
Code:
Imports System.TransactionsCode:
try
using scope as new TransactionScope()
DataAdaptor.Update(Table)
scope.Complete()
end using
catch ex as exception
throw ex
end trySample 2.
Code:
Imports System.TransactionsCode:
Using scope as new TransactionScope()
try
DataAdaptor.Update(Table)
scope.Complete()
catch
throw ex
end try
End using