472,127 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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.InvalidOperationException: The SqlCommand is currently busy Open, Fetching.

Source Error:


Line 794: SqlTrans.Commit()
Line 795: Else
Line 796: SqlTrans.Rollback()
Line 797: End If
Line 798: MyConnection.Close()


Source File: D:\Intranet\EFormApplication\preview\PMRF.aspx Line: 796

Stack Trace:


[InvalidOperationException: The SqlCommand is currently busy Open, Fetching.]
System.Data.SqlClient.SqlCommand.set_Transaction(S qlTransaction value) +57
System.Data.SqlClient.SqlTransaction.GetServerTran sactionLevel() +59
System.Data.SqlClient.SqlTransaction.CheckTransact ionLevelAndZombie() +63
System.Data.SqlClient.SqlTransaction.Rollback() +73
ASP.PMRF_aspx.btnApprove_Click(Object sender, EventArgs e) in D:\Intranet\EFormApplication\preview\PMRF.aspx:796
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292



Part of the code as below:
Expand|Select|Wrap|Line Numbers
  1. try
  2. Cmd6.Transaction = SqlTrans
  3.     objDRReq = Cmd6.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  4.  
  5.                 If objDRReq.Read() Then
  6.  
  7.                     fReqFormID = objDRReq("ReqForm_ID")
  8.                     fRequestorID = objDRReq("Requestor_ID")
  9.                     fReqName = objDRReq("ReqName")
  10.                     fEFormID = objDRReq("EForm_ID")
  11.                     fEFormName = objDRReq("EForm_Name")
  12.                     fReqDate = objDRReq("ReqDate")
  13.                     fReqTime = objDRReq("ReqTime")
  14.                     fJustification = objDRReq("Justification")
  15.  
  16.                 End If
  17.                 objDRReq.Close()
  18.             catch
  19.                 BooTrans = true
  20.             end try
  21.  
  22. ...
  23. ...
  24. ...
  25.       try
  26.                     Cmd8.Transaction = SqlTrans
  27.                     objDRCount = Cmd8.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  28.                     If objDRCount.Read() Then
  29.                         CountNum = objDRCount("Num")      '  Count the total number of response (approve or reject) form the approver '              
  30.                     End If
  31.                     objDRCount.Close()
  32.                    catch
  33.                        BooTrans = true
  34.                    end try
  35. ...
  36. ...
  37. ...
  38.  
  39.         If BooTrans = false Then
  40.             SqlTrans.Commit()            
  41.         Else
  42.             SqlTrans.Rollback()
  43.         End If
  44.              MyConnection.Close()
  45.  
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.... :-)
Jan 28 '08 #1
2 2489
leoiser
41
I am not clear about the coding... if you are doing any insert/delete/upate then only use the transactions.Are you doing? otherwise no need of transactions



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.InvalidOperationException: The SqlCommand is currently busy Open, Fetching.

Source Error:


Line 794: SqlTrans.Commit()
Line 795: Else
Line 796: SqlTrans.Rollback()
Line 797: End If
Line 798: MyConnection.Close()


Source File: D:\Intranet\EFormApplication\preview\PMRF.aspx Line: 796

Stack Trace:


[InvalidOperationException: The SqlCommand is currently busy Open, Fetching.]
System.Data.SqlClient.SqlCommand.set_Transaction(S qlTransaction value) +57
System.Data.SqlClient.SqlTransaction.GetServerTran sactionLevel() +59
System.Data.SqlClient.SqlTransaction.CheckTransact ionLevelAndZombie() +63
System.Data.SqlClient.SqlTransaction.Rollback() +73
ASP.PMRF_aspx.btnApprove_Click(Object sender, EventArgs e) in D:\Intranet\EFormApplication\preview\PMRF.aspx:796
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292



Part of the code as below:
Expand|Select|Wrap|Line Numbers
  1. try
  2. Cmd6.Transaction = SqlTrans
  3.     objDRReq = Cmd6.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  4.  
  5.                 If objDRReq.Read() Then
  6.  
  7.                     fReqFormID = objDRReq("ReqForm_ID")
  8.                     fRequestorID = objDRReq("Requestor_ID")
  9.                     fReqName = objDRReq("ReqName")
  10.                     fEFormID = objDRReq("EForm_ID")
  11.                     fEFormName = objDRReq("EForm_Name")
  12.                     fReqDate = objDRReq("ReqDate")
  13.                     fReqTime = objDRReq("ReqTime")
  14.                     fJustification = objDRReq("Justification")
  15.  
  16.                 End If
  17.                 objDRReq.Close()
  18.             catch
  19.                 BooTrans = true
  20.             end try
  21.  
  22. ...
  23. ...
  24. ...
  25.       try
  26.                     Cmd8.Transaction = SqlTrans
  27.                     objDRCount = Cmd8.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  28.                     If objDRCount.Read() Then
  29.                         CountNum = objDRCount("Num")      '  Count the total number of response (approve or reject) form the approver '              
  30.                     End If
  31.                     objDRCount.Close()
  32.                    catch
  33.                        BooTrans = true
  34.                    end try
  35. ...
  36. ...
  37. ...
  38.  
  39.         If BooTrans = false Then
  40.             SqlTrans.Commit()            
  41.         Else
  42.             SqlTrans.Rollback()
  43.         End If
  44.              MyConnection.Close()
  45.  
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.... :-)
Jan 29 '08 #2
I am not clear about the coding... if you are doing any insert/delete/upate then only use the transactions.Are 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.
Feb 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by S Shulman | last post: by
111 posts views Thread by =?Utf-8?B?bWFyaw==?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.