473,499 Members | 1,483 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 1368
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
10018
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...
2
11325
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...
3
7517
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....
2
2787
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...
6
1179
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...
0
991
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...
0
1214
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...
7
1612
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...
1
5702
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... ...
2
10733
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: ...
0
7006
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
7215
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
7385
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...
0
5467
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
3096
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...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
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 ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
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...

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.