473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rollback issue

I have a C# application that creates a SqlConnection object with an ADO
connection string and then sets up a SQlTransaction object for that
connection. Several records are posted to different tables in the
database within this transaction. All these tables uses an identity
element as their primary key. If the transaction fails, the records are
rolled back, but the identity elements are not reset. In other words,
if the last good record had an identity of 1000, and I roll back a
record that was assigned 1001, the next good record end up with an
identity value of 1002. I have not been able to find information as to
whether this behavior is by design, but it seems to me that if I do a
rollback, these identity elements should also be rolled back. Is this
behavior a bug?

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #1
1 1376
No - this is by design, to avoid processes blocking each other. It the
IDENTITY state was included in the transaction, then no other process
could get a new value until the first process committed. See also this
thread:

http://groups.google.ch/group/comp.d...448795a58d94b9

In general, you use IDENTITY where you need an artificial key and you
don't care what the key values are. If you need sequential values with
no gaps, or if you want the key values to have some meaning, then it
isn't a good solution.

If this isn't helpful, then you should probably give some more
information about exactly what you need to do, and why the IDENTITY
values matter to your application.

Simon

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10029
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
2
11333
by: Gert Schumann | last post by:
I want to delete just parts of tables, so I can't use 'TRUNCATE'. As I want to delete about millions of lines, I need a very big rollback segment. The best way would be to delete without using rollback because the delete really takes a lot of time copying all data into the rollback file. Is this possible with oracle? Many thanks for any...
3
7520
by: level8 | last post by:
Hi, Everybody, I'm a Hungarian SQL user and I need a little help for SQL Server 7 ! I protect my table against bad data with a trigger. I use ROLLBACK and RAISERROR statement in this trigger. Users can get my error message after manual input, but the stored procedure always cancel because of ROLLBACK. So the input program dont't have...
2
2796
by: mahajan.sanjeev | last post by:
Hi, I am having problems with rollback using the SQLTransaction object. I am trying to insert records in two tables in a transaction. I want to rollback all the changes if any exception occurs in any of the inserts. But the SQLTransaction object only rolls back the inserts that happen before an exception. All inserts after the exception go...
6
1187
by: Wangkhar | last post by:
Hi Having a little issue... is it possible to have multiple connections all get rolled back to the same point? I have a small database that seems to have been busy - but magically lost 5 hours of data (several 100k records...) This is across multiple databases. In one of them I do have a large identity gap - in the others the...
0
995
by: Ahmet | last post by:
Hi All I am developing a database application on Oracle 8.1.7 I have two types of programs one of which is C++ servers and the other one is C# client froms. On database I have SP and calling them from both server and client. In my sp code, there is one Rollback statement in case of an error and when this sp is called from C++ code...
0
1224
by: Jim Heavey | last post by:
I have tested a procedure in TOAD and it functions as expected, meaning for this particular transaction it returns and error message and performs a rollback within the procedure. When I call this stored procedure from within ASP.Net with the same data, The procedure returns an error which is caught by my try-catch block and it provides the...
7
1619
by: Rich | last post by:
Hello, I have an SP that inserts data into a sqlserver table. If a condition is not met within the SP after the data has been inserted into the table, the SP will rollback the insert. If I were to write the same procedure as inline sql in a VB2005 app cmd.CommandText = "Insert Into tbl1 Values(' & txt1.Text & ')" ....
1
5723
by: cheesey_toastie | last post by:
I have a long query which I have set off and would like to stop, and rename one of the tables used. My query is due to my lack of understanding of the underlying structure of MSSQL-Server... So say and update updates TABLE_A and I stop it, whilst this transaction is rolling back I attempt to rename TABLE_A to TABLE_A_OLD and rename a...
2
10754
by: Ian Boyd | last post by:
We're encountering a situation where we're encountering a deadlock, and someone's been made the deadlock victim. But after that, DB2 refuses to run any SQL, and instead we get the error message: "Application must execute a rollback. The unit of work has already been rolled back in the database but other resource managers involved in this...
0
7665
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...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
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...
1
5484
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...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
924
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...

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.