I'm using following for a simple database application:
- SQL Server Compact Edition .sdf file as database, with int primary key IDs.
- Typed DataSet and BindingSource as data access layer
- DataGridView for displaying data.
My problem is, I'm having trouble with the last inserted record/row ID. When I add a row to datagridview, using Append button of a navigator component, the ID of the new record/row is -1. It's still -1 even after save data to database using TableAdapter.Update(). I know I can get last ID using a seperate query with @@identity or scope_identity() but it doesn't sound right that you just have to use another query to update your data, manually at that. Am I missing something here? Is there an automatic way to update your data after saving to database and getting the ID of the record you just inserted?
Also, I saw a "refresh the datatable" option in dataset designer->table adapter configuration->advanced window, but it's disabled for some reason. But I don't know if it's related..
I'd appreciate any help with this..