Re: DataSet auto increment problem
- From: "RobinS" <RobinS@xxxxxxxxxxxxxxx>
- Date: Wed, 30 May 2007 00:04:43 -0700
Make sure that your update query is not trying to insert or update that
column. That's the only reason I can think of for it to do this to you.
Robin S.
---------------------------------------
"Mark" <Mark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E6C29340-8ED2-485B-B36B-1E35858A095E@xxxxxxxxxxxxxxxx
Hi Everyone:
I have set up a dataset that uses an auto increment field that is set to
start at minus one and step by minus one when I add a new record to the
dataset.
Example dataset:
1. Existing Record 1
2. Existing Record 2
3. Existing Record 3
4. Existing Record 4
5. Existing Record 5
The ID field is an auto increment field in SQL Server. To prevent
accidental
data corruption, whenever I add a new record to the dataset I start
with -1.
So the dataset will look like this when I add new records:
1. Existing Record 1
2. Existing Record 2
3. Existing Record 3
4. Existing Record 4
5. Existing Record 5
-1. 1st New Record
-2. 2nd New Record
-3. 3rd New Record
Here is my problem when I try to save the new record into the dataset I
get
the following error:
"Constraint Exception was unhandled. Column 'ID' is constrained to be
unique. Value '4' is already present."
I don't understand why this is happening. The dataset's auto increment
field
should put a -1 on the new record I'm adding. Instead it looks like it is
starting at the last record '5', subtracts one to get four and is trying
to
place the new information in record four instead of creating a new record
in
the dataset and starting the ID number at -1.
What is going on?
Thank you,
--
Mark
.
- Prev by Date: RE: DataSet auto increment problem
- Next by Date: Re: Transaction problems
- Previous by thread: RE: DataSet auto increment problem
- Index(es):
Relevant Pages
|