I would presume the DB engine is keeping the highest previously assigned value and using that for the autoincrement.
If it didn't do it that way, every delete would require recalculation of that field on every delete.
Main Topics
Browse All TopicsHere is my problem
In form load i've got
this.ogiSelectEventBinding
In form close I've got something like this
this.ogiSelectEventBinding
this.ogiSelectEventTableAd
DataRowView serv = (DataRowView)this.ogiSelec
ogiSelectEventRow ser = (ogiSelectEventRow)serv.Ro
int id = ser.evtIdent;
evtIdent is autoincrement field in a database table.
Let's imagine I've got records with evtIdent 1,2,3.
There were also records with evtIdent 4,5, but they were delete
After initial AddNew()
ser.evtIdent has value 4
After Update() the record is save to a table in database with evtIdent value 6
But ser.evtIdent stays 4.
What should I do to force ser.evtIdent to follow what is really saved in a table?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've posted most my relevant code
Maybe only this
this.ogiSelectEventTableAd
The other is autocreated in a huge DataSet strongly typed and such a things.
One thing i've just noticed is that from some unknown reason the autocreated evtIdent field in tabbleadapter has no Unique property set.
Similar such a fields from other tables has it set.
Maybe something goes wrong in tableadapter autocreation. But where to check I don't know.
this is what i was saying.....
remove auto number property from data base and make eventid field just a number in database.
you said
"One thing i've just noticed is that from some unknown reason the autocreated evtIdent field in tabbleadapter has no Unique property set."
there I am saying set "AutoIncrement" for eventid field in tabbleadapter.
this has a effect of
database not having "Auto number" for eventid but in the program tabbleadapter's eventid field has "AutoIncrement" property.
This will make eventid field in your program to be written to database.
1. No i won't remove autoincrement feature from the database field.
Otherwise it stops working completely.
2. evtIdent IS saved to database
The problem is that saved value is different that this hold in tableadapter.
I'm searching a way to keep this values synchronized.
3. I've managed to have Unique property set for evtIdent field while autocreating Tableadapter.
However this doesn't solve a problem with evtIdent not reflecting the real value saved in database table.
Business Accounts
Answer for Membership
by: nsangaPosted on 2008-03-09 at 09:50:48ID: 21081807
you said...
"There were also records with evtIdent 4,5, but they were deleted"
are they deleted from data base......what database you are using.....
I think, data base doesn't reuse the numbers even if the rows are deleted and so new row has got 6. But in you dataset/datatable the event id is given a new value 4.
why do you need a autonumber, you can do this way
1)remove auto number property from data base and make eventid just a number
2) once you read the data base into your datatable, then you set the eventid as autonumber.
3) while update to database, the values in data table will only go to data base.