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. Web Development
  3. ASP.NET
  4. sql server transactions

sql server transactions

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasesql-server
6 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.
  • W Offline
    W Offline
    wilf57
    wrote on last edited by
    #1

    I'm using asp.net 2.0 and sql server 2000. I'm using a transaction to wrap the execution of 2 insert commands on the sql server together. On the development system everything works fine. On the target system it executes the 2 inserts properly but then displays the error message: Sqltransaction is finished and cannot be used anymore the stack: System.Data.SqlClient.SqlTransaction.ZombieCheck() +701167 System.Data.SqlClient.SqlTransaction.Rollback() +120 kurz.GV1_RowCommand(Object sender, GridViewCommandEventArgs e) +2901 System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +104 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +76 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +200 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +170 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5612 does it try to make a rollback? but the things are inserted properly. And then it makes the funny Zombiecheck and maybe found one. Did anybody solve a similar issue? Thanks in advance. Wilfried.

    N 1 Reply Last reply
    0
    • W wilf57

      I'm using asp.net 2.0 and sql server 2000. I'm using a transaction to wrap the execution of 2 insert commands on the sql server together. On the development system everything works fine. On the target system it executes the 2 inserts properly but then displays the error message: Sqltransaction is finished and cannot be used anymore the stack: System.Data.SqlClient.SqlTransaction.ZombieCheck() +701167 System.Data.SqlClient.SqlTransaction.Rollback() +120 kurz.GV1_RowCommand(Object sender, GridViewCommandEventArgs e) +2901 System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +104 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +76 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +200 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +170 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5612 does it try to make a rollback? but the things are inserted properly. And then it makes the funny Zombiecheck and maybe found one. Did anybody solve a similar issue? Thanks in advance. Wilfried.

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      It will be much more helpful if you can post some sample code of transaction what you wrote and the data you inserted.. :cool:


      printf("Navaneeth!!") www.w3hearts.com

      W 1 Reply Last reply
      0
      • N N a v a n e e t h

        It will be much more helpful if you can post some sample code of transaction what you wrote and the data you inserted.. :cool:


        printf("Navaneeth!!") www.w3hearts.com

        W Offline
        W Offline
        wilf57
        wrote on last edited by
        #3

        ok thats the code: I execute it in the gridview_RowCommand() and on the development system everything is great. sqlKont = "Update tbnKontBib set fest=fest+ CONVERT( money," & "'" & Komma2Punkt(diffFest) & "') " & _ "where bh='" & Session("bHalle") & "'" sql = "Insert into tbOrder(artnr, odatum, bh, oanz, opreis, bhoper) Values( " & _ "'" & artnum & "'" & "," & _ "'" & Date.Now.ToShortDateString & "'" & "," & _ "'" & Session("bHalle") & "'" & "," & _ "'" & anzBest & "'" & "," & _ "CONVERT( money," & "'" & Komma2Punkt(preis) & "')" & "," & _ "'" & Session("bUser") & "')" 'Ausfuehrung mit Transaction Try t = conn.BeginTransaction cmd = New SqlCommand(sqlKont, conn) cmd.Transaction = t erg = cmd.ExecuteNonQuery() If erg <> 1 Then 'Fehler MsgBox("K-Fehler in Bestellung! Bitte Administrator benachrichtigen!", MsgBoxStyle.Critical, "!!! Achtung !!!") t.Rollback() GoTo ende End If cmd = New SqlCommand(sql, conn) cmd.Transaction = t erg = cmd.ExecuteNonQuery() If erg <> 1 Then 'Fehler MsgBox("O-Fehler in Bestellung! Bitte Administrator benachrichtigen!", MsgBoxStyle.Critical, "!!! Achtung !!!") t.Rollback() GoTo ende End If t.Commit() MsgBox("Ihre Bestellung wurde ausgeführt!", MsgBoxStyle.Exclamation, "Bestellvorgang") Catch ex As Exception t.Rollback() MsgBox("Ihre Bestellung ist fehlgeschlagen! Bitte wiederholen sie die Bestellung.", MsgBoxStyle.Critical, "Bestellvorgang") End Try ende: conn.Close() Bye Wilfried

        C 1 Reply Last reply
        0
        • W wilf57

          ok thats the code: I execute it in the gridview_RowCommand() and on the development system everything is great. sqlKont = "Update tbnKontBib set fest=fest+ CONVERT( money," & "'" & Komma2Punkt(diffFest) & "') " & _ "where bh='" & Session("bHalle") & "'" sql = "Insert into tbOrder(artnr, odatum, bh, oanz, opreis, bhoper) Values( " & _ "'" & artnum & "'" & "," & _ "'" & Date.Now.ToShortDateString & "'" & "," & _ "'" & Session("bHalle") & "'" & "," & _ "'" & anzBest & "'" & "," & _ "CONVERT( money," & "'" & Komma2Punkt(preis) & "')" & "," & _ "'" & Session("bUser") & "')" 'Ausfuehrung mit Transaction Try t = conn.BeginTransaction cmd = New SqlCommand(sqlKont, conn) cmd.Transaction = t erg = cmd.ExecuteNonQuery() If erg <> 1 Then 'Fehler MsgBox("K-Fehler in Bestellung! Bitte Administrator benachrichtigen!", MsgBoxStyle.Critical, "!!! Achtung !!!") t.Rollback() GoTo ende End If cmd = New SqlCommand(sql, conn) cmd.Transaction = t erg = cmd.ExecuteNonQuery() If erg <> 1 Then 'Fehler MsgBox("O-Fehler in Bestellung! Bitte Administrator benachrichtigen!", MsgBoxStyle.Critical, "!!! Achtung !!!") t.Rollback() GoTo ende End If t.Commit() MsgBox("Ihre Bestellung wurde ausgeführt!", MsgBoxStyle.Exclamation, "Bestellvorgang") Catch ex As Exception t.Rollback() MsgBox("Ihre Bestellung ist fehlgeschlagen! Bitte wiederholen sie die Bestellung.", MsgBoxStyle.Critical, "Bestellvorgang") End Try ende: conn.Close() Bye Wilfried

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Your code is susceptable to a SQL Injection attack: See SQL Injection Attacks and Tips on How to Prevent Them[^]


          Upcoming events: * Glasgow: Introduction to AJAX (2nd May), SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

          W 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Your code is susceptable to a SQL Injection attack: See SQL Injection Attacks and Tips on How to Prevent Them[^]


            Upcoming events: * Glasgow: Introduction to AJAX (2nd May), SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

            W Offline
            W Offline
            wilf57
            wrote on last edited by
            #5

            Ok I'll use parameters later, but if you could give me a hint to my problem it would be a great help. Thanks Wilfried.

            W 1 Reply Last reply
            0
            • W wilf57

              Ok I'll use parameters later, but if you could give me a hint to my problem it would be a great help. Thanks Wilfried.

              W Offline
              W Offline
              wilf57
              wrote on last edited by
              #6

              Ok I solved that, the MsgBox() calls were the reason. When I pulled them out it works well on the targhet system

              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