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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. SqlTransaction

SqlTransaction

Scheduled Pinned Locked Moved ASP.NET
questiondatabasehelptutorialannouncement
2 Posts 2 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.
  • V Offline
    V Offline
    vjvjvjvj
    wrote on last edited by
    #1

    Hi, Probably this is not a question to ask in this forum . but I could not decide. Just putting things in abstract level. I have a primary function which insert some rows to DB0 tables and calls subFun1 and SubFUn2 who connection to different databases and insert some rows in tables in there. Say I get error in subFun2 function I need to rollback everything what was inserted till that point from DB0 tables, DB1 tables and may from DB2 tables also. How to achive that here? If exception occurs in subFun2, it will throw exception to primary function and only DB2 and DB0 transactions will be rolled back but not from the DB1 transactions. Any workaround for this sub primaryfunction() try SqlConnection0 = Connection to DB0 SqlTransaction0 Insert/Update some table call function SubFun1 call function subFun1 call function subFun2 SqlTransaction0.commit() catch exception SqlTransaction0.rollback() end sub sub SubFun1 try SqlConnection1 = Connection to DB 1 SqlTransaction1 call function SubFun1 call function subFun1 call function subFun2 SqlTransaction1.commit() catch exception SqlTransaction1.rollback() throw exception end sub sub SubFun2 try SqlConnection2 = connection to DB2 SqlTransaction2 Insert/Update some table SqlTransaction2.commit() catch exception SqlTransaction2.rollback() throw exception end sub

    P 1 Reply Last reply
    0
    • V vjvjvjvj

      Hi, Probably this is not a question to ask in this forum . but I could not decide. Just putting things in abstract level. I have a primary function which insert some rows to DB0 tables and calls subFun1 and SubFUn2 who connection to different databases and insert some rows in tables in there. Say I get error in subFun2 function I need to rollback everything what was inserted till that point from DB0 tables, DB1 tables and may from DB2 tables also. How to achive that here? If exception occurs in subFun2, it will throw exception to primary function and only DB2 and DB0 transactions will be rolled back but not from the DB1 transactions. Any workaround for this sub primaryfunction() try SqlConnection0 = Connection to DB0 SqlTransaction0 Insert/Update some table call function SubFun1 call function subFun1 call function subFun2 SqlTransaction0.commit() catch exception SqlTransaction0.rollback() end sub sub SubFun1 try SqlConnection1 = Connection to DB 1 SqlTransaction1 call function SubFun1 call function subFun1 call function subFun2 SqlTransaction1.commit() catch exception SqlTransaction1.rollback() throw exception end sub sub SubFun2 try SqlConnection2 = connection to DB2 SqlTransaction2 Insert/Update some table SqlTransaction2.commit() catch exception SqlTransaction2.rollback() throw exception end sub

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      According to my understanding Create a Connection and Transaction object in primary function for both sub function and then pass it to the both sub function instead of creating in sub functions. Then you can easily handle transaction control in Primary function.

      Parwej Ahamad

      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