VB-WEB:The SqlCommand is currently busy Open, Fetching.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SunshineInTheRain
    New Member
    • Jan 2008
    • 14

    #1

    VB-WEB:The SqlCommand is currently busy Open, Fetching.

    I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some table inserted but some not. But I get this error:

    The SqlCommand is currently busy Open, Fetching.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidO perationExcepti on: The SqlCommand is currently busy Open, Fetching.

    Source Error:


    Line 794: SqlTrans.Commit ()
    Line 795: Else
    Line 796: SqlTrans.Rollba ck()
    Line 797: End If
    Line 798: MyConnection.Cl ose()


    Source File: D:\Intranet\EFo rmApplication\p review\PMRF.asp x Line: 796

    Stack Trace:


    [InvalidOperatio nException: The SqlCommand is currently busy Open, Fetching.]
    System.Data.Sql Client.SqlComma nd.set_Transact ion(SqlTransact ion value) +57
    System.Data.Sql Client.SqlTrans action.GetServe rTransactionLev el() +59
    System.Data.Sql Client.SqlTrans action.CheckTra nsactionLevelAn dZombie() +63
    System.Data.Sql Client.SqlTrans action.Rollback () +73
    ASP.PMRF_aspx.b tnApprove_Click (Object sender, EventArgs e) in D:\Intranet\EFo rmApplication\p review\PMRF.asp x:796
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +57
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +18
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
    System.Web.UI.P age.ProcessRequ estMain() +1292



    Part of the code as below:
    Code:
    try
    Cmd6.Transaction = SqlTrans
    	objDRReq = Cmd6.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    							
    	            If objDRReq.Read() Then
    					
    	                fReqFormID = objDRReq("ReqForm_ID")
    	                fRequestorID = objDRReq("Requestor_ID")
    	                fReqName = objDRReq("ReqName")
    	                fEFormID = objDRReq("EForm_ID")
    	                fEFormName = objDRReq("EForm_Name")
    	                fReqDate = objDRReq("ReqDate")
    	                fReqTime = objDRReq("ReqTime")
    	                fJustification = objDRReq("Justification")
    					    
    	            End If
    	            objDRReq.Close()
    			catch
    				BooTrans = true
    			end try
    
    ...
    ...
    ...
          try
                    	Cmd8.Transaction = SqlTrans
                    	objDRCount = Cmd8.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
                        If objDRCount.Read() Then
                            CountNum = objDRCount("Num")      '  Count the total number of response (approve or reject) form the approver '		      
                        End If
                        objDRCount.Close()
                   	catch
                   		BooTrans = true
                   	end try
    ...
    ...
    ...
     
    		If BooTrans = false Then
    			SqlTrans.Commit()			
    		Else
    			SqlTrans.Rollback()
    		End If
         	    MyConnection.Close()
    Am I using the correct way in code above? Is there any suggestion on how to modify the existing code using the same transaction? Maybe I do not so understand on how to using the transaction code... Appreciating for any suggestion and help given.... :-)
    Last edited by SunshineInTheRain; Jan 28 '08, 02:58 AM. Reason: make the post title more clarity of what language it used
  • leoiser
    New Member
    • Jul 2007
    • 41

    #2
    I am not clear about the coding... if you are doing any insert/delete/upate then only use the transactions.Ar e you doing? otherwise no need of transactions



    Originally posted by SunshineInTheRa in
    I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some table inserted but some not. But I get this error:

    The SqlCommand is currently busy Open, Fetching.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidO perationExcepti on: The SqlCommand is currently busy Open, Fetching.

    Source Error:


    Line 794: SqlTrans.Commit ()
    Line 795: Else
    Line 796: SqlTrans.Rollba ck()
    Line 797: End If
    Line 798: MyConnection.Cl ose()


    Source File: D:\Intranet\EFo rmApplication\p review\PMRF.asp x Line: 796

    Stack Trace:


    [InvalidOperatio nException: The SqlCommand is currently busy Open, Fetching.]
    System.Data.Sql Client.SqlComma nd.set_Transact ion(SqlTransact ion value) +57
    System.Data.Sql Client.SqlTrans action.GetServe rTransactionLev el() +59
    System.Data.Sql Client.SqlTrans action.CheckTra nsactionLevelAn dZombie() +63
    System.Data.Sql Client.SqlTrans action.Rollback () +73
    ASP.PMRF_aspx.b tnApprove_Click (Object sender, EventArgs e) in D:\Intranet\EFo rmApplication\p review\PMRF.asp x:796
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +57
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +18
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
    System.Web.UI.P age.ProcessRequ estMain() +1292



    Part of the code as below:
    Code:
    try
    Cmd6.Transaction = SqlTrans
    	objDRReq = Cmd6.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    							
    	            If objDRReq.Read() Then
    					
    	                fReqFormID = objDRReq("ReqForm_ID")
    	                fRequestorID = objDRReq("Requestor_ID")
    	                fReqName = objDRReq("ReqName")
    	                fEFormID = objDRReq("EForm_ID")
    	                fEFormName = objDRReq("EForm_Name")
    	                fReqDate = objDRReq("ReqDate")
    	                fReqTime = objDRReq("ReqTime")
    	                fJustification = objDRReq("Justification")
    					    
    	            End If
    	            objDRReq.Close()
    			catch
    				BooTrans = true
    			end try
    
    ...
    ...
    ...
          try
                    	Cmd8.Transaction = SqlTrans
                    	objDRCount = Cmd8.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
                        If objDRCount.Read() Then
                            CountNum = objDRCount("Num")      '  Count the total number of response (approve or reject) form the approver '		      
                        End If
                        objDRCount.Close()
                   	catch
                   		BooTrans = true
                   	end try
    ...
    ...
    ...
     
    		If BooTrans = false Then
    			SqlTrans.Commit()			
    		Else
    			SqlTrans.Rollback()
    		End If
         	    MyConnection.Close()
    Am I using the correct way in code above? Is there any suggestion on how to modify the existing code using the same transaction? Maybe I do not so understand on how to using the transaction code... Appreciating for any suggestion and help given.... :-)

    Comment

    • SunshineInTheRain
      New Member
      • Jan 2008
      • 14

      #3
      Originally posted by leoiser
      I am not clear about the coding... if you are doing any insert/delete/upate then only use the transactions.Ar e you doing? otherwise no need of transactions
      Yes, I'm doing and a lot, however problem solved. Appreciating your kindness to help and thank you for your reply.

      Comment

      Working...