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 - set ANSI_NULLS ON
-
set QUOTED_IDENTIFIER ON
-
GO
-
ALTER procedure [dbo].[updatecommand]
-
as
-
declare @speed int
-
declare @ignition int
-
declare @basestationname varchar(50)
-
declare @registrationno varchar(50)
-
declare @exp int
-
set @exp=null
-
-
begin
-
declare opencur cursor for
-
select registrationno,speed,ignition,basestationname from gpsdata where datediff(mi,gps_datetime,getdate())>10 order by gps_datetime
-
end
-
-
open opencur
-
-
fetch next from opencur into @registrationno,@speed,@ignition,@basestationname
-
WHILE (@@FETCH_STATUS = 0)
-
begin
-
if(@speed<>0 or @ignition<>0 or @basestationname<>null)
-
begin Tran
-
update gpsdata set speed=0,ignition=0,basestationname=null where registrationno=@registrationno
-
set @exp=@@error
-
if (@exp<>null)
-
rollback Tran
-
else
-
begin
-
update gpsdata_history set speed=0,ignition=0,basestationname=null where registrationno=@registrationno
-
set @exp=@@error
-
if(@exp<>null)
-
rollback Tran
-
-
end
-
-
fetch next from opencur into @registrationno,@speed,@ignition,@basestationname
-
-
commit Tran
-
-
end
-
close opencur
-
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 - MyCon.Open();
-
SqlCommand MyCmd = new SqlCommand("updatecommand", MyCon);
-
MyCmd.CommandType = CommandType.StoredProcedure;
-
MyCmd.ExecuteNonQuery();
-
MyCon.Close();
Kindly help
Regards
cmrhema
0 3591 Sign in to post your reply or Sign up for a free account.
Similar topics |
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 ?
|
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
|
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...
|
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.
|
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?
| |
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'...
|
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"
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |