A lot of databases will only use your start value if there are no values
greater than it. If there are greater values, it will go one over that so
that it can always just do an inc for each new record.
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com Cubicle Wars -
http://www.windwardreports.com/film.htm [quoted text, click to view] "Mark" wrote:
> 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,
>
> --
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.
---------------------------------------
[quoted text, click to view] "Mark" <Mark@discussions.microsoft.com> wrote in message
news:E6C29340-8ED2-485B-B36B-1E35858A095E@microsoft.com...
> 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