Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to ROLLBACK TRANSACTION on client level

How to ROLLBACK TRANSACTION on client level

Scheduled Pinned Locked Moved Database
databasecsharpsharepointsql-serversysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _J_
    wrote on last edited by
    #1

    Suppose i connect to db (SQL Server) from the client (.NET) and call to some store procedure, in this sp i start transaction (BEGIN TRANSACTION) and before COMMIT or RALLBACK an error happen that imidietly stop the execution of stored procedure, In the client i cacth this error but what about an open transaction ??? HOW to rollback in the client??? ------------------------------------ To study, study and only to study

    L T 2 Replies Last reply
    0
    • _ _J_

      Suppose i connect to db (SQL Server) from the client (.NET) and call to some store procedure, in this sp i start transaction (BEGIN TRANSACTION) and before COMMIT or RALLBACK an error happen that imidietly stop the execution of stored procedure, In the client i cacth this error but what about an open transaction ??? HOW to rollback in the client??? ------------------------------------ To study, study and only to study

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      I am not an expert in SQL by any means, and so I don't know if it is possible to do what you want. But if you could start you transaction on the client side, then you could undo everything. See SqlTransaction class. -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      1 Reply Last reply
      0
      • _ _J_

        Suppose i connect to db (SQL Server) from the client (.NET) and call to some store procedure, in this sp i start transaction (BEGIN TRANSACTION) and before COMMIT or RALLBACK an error happen that imidietly stop the execution of stored procedure, In the client i cacth this error but what about an open transaction ??? HOW to rollback in the client??? ------------------------------------ To study, study and only to study

        T Offline
        T Offline
        turbochimp
        wrote on last edited by
        #3

        Short answer: try SET XACT_ABORT ON... "If a run-time statement error (such as a constraint violation) occurs in a batch, the default behavior in SQL Server is to roll back only the statement that generated the error. You can change this behavior using the SET XACT_ABORT statement. After SET XACT_ABORT ON is executed, any run-time statement error causes an automatic rollback of the current transaction. Compile errors, such as syntax errors, are not affected by SET XACT_ABORT. It is the responsibility of the programmer to code the application to specify the correct action (COMMIT or ROLLBACK) if a run-time or compile error occurs." -- SQL Server Books Online A better answer would be to include error handling. There's a very good article here[^] that describes one strategy for getting more predictable results from stored procedures through error handling.

        The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

        _ 1 Reply Last reply
        0
        • T turbochimp

          Short answer: try SET XACT_ABORT ON... "If a run-time statement error (such as a constraint violation) occurs in a batch, the default behavior in SQL Server is to roll back only the statement that generated the error. You can change this behavior using the SET XACT_ABORT statement. After SET XACT_ABORT ON is executed, any run-time statement error causes an automatic rollback of the current transaction. Compile errors, such as syntax errors, are not affected by SET XACT_ABORT. It is the responsibility of the programmer to code the application to specify the correct action (COMMIT or ROLLBACK) if a run-time or compile error occurs." -- SQL Server Books Online A better answer would be to include error handling. There's a very good article here[^] that describes one strategy for getting more predictable results from stored procedures through error handling.

          The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

          _ Offline
          _ Offline
          _J_
          wrote on last edited by
          #4

          Thank u in andvance. ------------------------------------ To study, study and only to study

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups