Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27156

VS 2010 Catching errors while using System.Transaction in Using Statement?

$
0
0
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.

Code:

Imports System.Transactions
button save click:

Code:

try
  using scope as new TransactionScope()
      DataAdaptor.Update(Table)
      scope.Complete()
  end using
catch ex as exception
  throw ex
end try

or

Sample 2.

Code:

Imports System.Transactions
button save click:

Code:

Using scope as new TransactionScope()
  try
      DataAdaptor.Update(Table)
      scope.Complete()
  catch
      throw ex
  end try
End using


Viewing all articles
Browse latest Browse all 27156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>