Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this form in C#

I add an row, and update tableadapter. And then the primary key is 14098 in datagridview while the same row has 14117 on the server.

When i update again i get an dbconcurrency exception.

The primary key is int and autoincremeant is true, and seed/increment is set to 1 on both server and visual studio properties.

Please help
Posted

When you use identity column to autoincrement value on inserting data, it will always be incremented whether the data you wanted to insert was successfully inserted or not. As a result, the identity column will have some empty values. This page discusses the following problem. Link[^]
 
Share this answer
 
v2
Comments
MrDeej 19-Aug-11 12:47pm    
Hmm.. it seems like the same problem, but not any solution there :/
Ok, I have made a workaround by setting tableadapter fill right after tableadapter.update

Then the right primary key is used. But i think this is no good solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900