Access autonumber using dataset AddNew?

damal

New member
Joined
Mar 3, 2011
Messages
1
Programming Experience
Beginner
Hi all,

I have an "City Overview" on which i can add new cities. "Add City" will show a detailscreen of city on which you see the autonumber and city name (textboxes bound via dataset)

Autonumber is -1 by default for new records that haven't been saved yet. So after i give in a city name and press "Save", the -1 remains the same...

If i start editing the record & press "Save" a second time, vb.net throws an error (concurrency violation because of the -1). I'm using a dataset in datagridview to show my city overview...

How can i refresh the data on my detail screen after saving? Because the generated ID is not known?
 
With a proper database like SQL Server, that can be done when you save by adding a bit of extra SQL. In Access, it's not possible. You simply have to requery the database to get all the data again.
 
Back
Top