Community discussion forum

How to perform rollback from vb.net?

  • 1 month ago

    Hi, Please help me to perform rollback insert statement from vb.net. Thank You

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 1 month ago

    Hi,

    I am not 100%, but i think you will need to use something like the transaction capabilities of the datacommands to undo the changes made by an insert statement.

    Not having used them too much and with a horrid bug in the transaction services for Oracle stopping me from going forward with them, i can't really guide more than point you in their direction.

    Sorry

    Si

  • 1 month ago

    You can use TransactionScope in .NET 2.0.... it's really simple:

    Using ts As New TransactionScope()
        ' perform your database stuff here
        ' complete the transaction
            ' if you don't do this, you'll get the rollbacks you want
        ts.Complete()
    End Using
    

    Hope that helps!

  • 1 month ago

    Hi, I have found the way to rollback the sql transaction from vb.net.This is how it is done.

    ' dim trns as sqlTransaction=myConnection.BeginTransaction dim Cmd as SqlCommand=............'Sql stmt Cmd.Transaction=trns Cmd.ExecuteNonQuery trns.commit

    Note:Rollback is performed in the catch block

Post a reply

Enter your message below

Sign in or Join us (it's free).