473,796 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

375 Contributor
Hello
I am using Asp.net with VC# having backend SQL SERVER
I have written a procedure in sqlserver as below.
It does not throw any error in sqlserver.

This is the procedure

Expand|Select|Wrap|Line Numbers
  1. set ANSI_NULLS ON
  2. set QUOTED_IDENTIFIER ON
  3. GO
  4. ALTER procedure [dbo].[updatecommand]
  5. as
  6. declare @speed int
  7. declare @ignition int
  8. declare @basestationname varchar(50)
  9. declare @registrationno varchar(50)
  10. declare @exp int 
  11. set @exp=null
  12.  
  13. begin
  14. declare opencur cursor for 
  15. select registrationno,speed,ignition,basestationname from gpsdata where datediff(mi,gps_datetime,getdate())>10 order by gps_datetime
  16. end
  17.  
  18. open opencur
  19.  
  20. fetch next from opencur into @registrationno,@speed,@ignition,@basestationname
  21. WHILE (@@FETCH_STATUS = 0)
  22. begin
  23. if(@speed<>0 or @ignition<>0 or @basestationname<>null)
  24. begin Tran 
  25.     update gpsdata set speed=0,ignition=0,basestationname=null where registrationno=@registrationno
  26.     set @exp=@@error
  27.     if (@exp<>null)
  28.         rollback Tran
  29.     else
  30.     begin
  31.         update gpsdata_history set speed=0,ignition=0,basestationname=null where registrationno=@registrationno
  32.         set @exp=@@error
  33.         if(@exp<>null)
  34.              rollback Tran
  35.  
  36.     end
  37.  
  38. fetch next from opencur into @registrationno,@speed,@ignition,@basestationname
  39.  
  40.             commit Tran
  41.  
  42. end
  43. close opencur
  44. deallocate opencur
But when i execute the above procedure in asp.net i get the error
Commit Transaction has no corresponding Begin Tranasaction

This is code for asp.net
Expand|Select|Wrap|Line Numbers
  1. MyCon.Open();      
  2.         SqlCommand MyCmd = new SqlCommand("updatecommand", MyCon);
  3.         MyCmd.CommandType = CommandType.StoredProcedure;
  4.         MyCmd.ExecuteNonQuery();
  5.         MyCon.Close();
Kindly help
Regards
cmrhema
Sep 5 '07 #1
0 3591

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

Similar topics

3
11628
by: DP | last post by:
Is there any command exists as "commit transaction" ? begin transaction < DML1 stmts > begin transaction < DML2 stmts > rollback transaction commit transaction which set of DML will be commites to the database or none ?
1
10059
by: anders_tung | last post by:
Hi, I have a procedure which will call 3 functions. First function will update a record. Second function will delete a record. Third function will insert a record. Each function will return a zero if successful, otherwise return 1. My questions are
11
12722
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to read the new date. So process B starts "select ..." but does not get the previously inserted row. The timespan between commit and select is very short. (NOTE: two different sessions are used) Questions: 1.) Does commit when returning from call...
3
6644
by: Alberto | last post by:
I've a complex stored procedure, that makes a lot of insert, update, delete and so on. I would like to make some commits durint this sp, but of course they are not "real" commit because who call the sp could decide for a rollback. But I know that this commit has to be real. In fact, the transaction log grows really too much during the execution.
3
3899
by: Peter Kirk | last post by:
Hi there when working with database connections in C# is there a concept of "auto commit"? For instance, if I obtain a database connection in java I can set the auto-commit state to true or false. Is there something similar in C#, or how do I handle this - do I always have to start and end transactions and commit database updates myself?
1
4412
by: Horace | last post by:
Hello I am writing an ASP.NET / SQL-Server application and wanting to know when to connect/begin-transaction and commit/disconnect. I have a common module which I call at the beginning of Page_Load which, when instantiated performs the connect/begin-transaction. The page then does what it has to do (eg when a Save button is clicked it will do a read/write to the database within the btnSave_Clicked event). At the end of the 'event'...
2
1901
by: Jim Wilson | last post by:
The debug logs seem a little confusing. On sending a query something like this will show up: DEBUG: StartTransactionCommand LOG: query: select * from blah; DEBUG: ProcessQuery DEBUG: CommitTransactionCommand This is with auto commit off. My first reaction on seeing this was the auto commit setting must not work. Then I noticed that most things, even "begin"
2
2234
by: Ryan | last post by:
I've re-written a stored procedure and when I post the following code into the existing SP in EM, is saves OK. However, when I re-edit the SP, the last line 'Commit Transaction' has been removed. I cannot save the remainder of the SP as it throws error 208 (Invalid Object name #Max) about two of the temp tables I use when I post the entire script. It shows in a message box with the header : 'Microsoft SQL-DMO(ODBC SQLState:42S02) I...
1
1500
by: Scott Cupstid | last post by:
We are working on a VB.NET application using SQLClient command objects to post data to the underlying SQL Server 2000 database. The application is deployed in a multi-user environment with no more than 10 user accessing the database at any given time. The host server is supporting approximately 4 other active databases. In general, there are approximately 60 active connections on the server. The incident we are trying to resolve has...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.