473,408 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 2649
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

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

Similar topics

0
by: Techteam | last post by:
hi all, i am getting the following error in asp.net application " The compiler failed with error code 128. " After a abnormal shutdown of win 2000 , earlier it was working fine can any...
3
by: S Shulman | last post by:
Hi Does anyone know how to click a combobox control in VB so the entire list will be shown? Thank you, Shmuel Shulman
12
by: Tomas | last post by:
Hi, I have worked with VB.NET for half a year (semi-newbie). Currently I am looking around for some books for those that crossed the starting hurdle. There are too many books out there-make...
8
by: Bill Gower | last post by:
I want to store an SQL string into a table and then be able to run it later. Here is the insert command "insert into ProjectSQL(ProjectID, SQLID, SQLString) values( " & locProjectID & ", " &...
111
by: =?Utf-8?B?bWFyaw==?= | last post by:
Fact Poll I made the transition from (Borland) C++ to VB.NET around 2004. I have been happy with the choice. I find I can focus more on the problem and less on being "tidy" with VB. But, I...
4
by: airwot4 | last post by:
Hi all, I'm sure this is simple to answer but I have built a project exited VB Express. When I go back into VB Express and open the project no files appear (but I can open them manually) and...
1
by: Zephery | last post by:
Hi, I got some scripting experience with a few scripts and now I want to make a chess game online. What I mean: - You download a application and when you start it you get a inlog screen. If...
1
by: callsupport1 | last post by:
How can i open and display a power Point File with an extention of .ppt Thanks Steve
5
by: alem | last post by:
Hi all i could not joine MS Access table to VB the code i write below Private Sub Form_Load() Set cn = New ADODB.connection cn.Provider = "Microsoft.jet.oledb.4.0" cn.Open "C:\db1.mdb"...
1
by: rd75 | last post by:
I'm starting to brush up on my VB skills because a co worker of mine mentioned how she thinks that VB is going to fare very well during the upcoming recession. What do you all think? If these stats...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.