Roger Tranchez
5/30/2007 1:17:00 PM
Hello, WenYuan ...
You said:
> The solution for this issue is that you can set the AutoINcrementValue = -1
> and the seed to -1
I think it is not necessary as long as my update command does not transmit
the id to the database because the database creates it an I retrieve it later:
INSERT INTO PETICIONS_TRESORERIA_LIQUIDACIONS (codtreballador, persona,
data, descripcio, import, liquidat) VALUES
(@codtreballador,@persona,@data,@descripcio,@import,@liquidat) SET @id
=(select scope_identity()) ...
Also, my application cannot crash for duplicate keys now...
Thank you,
Roger Tranchez
..NET 2005 and DB developer
"WenYuan Wang [MSFT]" wrote:
> Dear Roger,
> Cool! Thanks for your clarify.
>
> Apparent, the last part in the insert command return a new ID. Thus,
> DataRowAction.Chang even fires.
>
> >As that line was not present, the program worked well on single user , but
> when more than one user
> >were working with the program, the ids generated were the same for more
> than one line and it caused
> >primary key violations.
>
> The solution for this issue is that you can set the AutoINcrementValue = -1
> and the seed to -1. This way, the value submitted to the db will always be
> negative, so the DB will always step in and assign it. Those way two
> versions of the app won't ever step on each other. Actually, there are
> many posts discussed on this issue. The best way is seting both
> AutoINcrementValue and seed to -1.
>
> Hope this helps. Please let me know if you meet any futher issue or have
> anything unclear. I'm glad to assist you.
> Have a great day,
> Sincerely,
> Wen Yuan.
>
>