473,386 Members | 1,793 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,386 software developers and data experts.

The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

375 256MB
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 3564

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

Similar topics

3
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...
1
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...
11
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...
3
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...
3
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...
1
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...
2
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:...
2
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. ...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.