Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi all

i have table in an access database

and i set ID field as autonumber

when i connect it to vb.net and use new record , ID will be less than zero

when i close form and open it again , ID will be positive number

why is that ?

how can i solve it ?
Posted

1 solution

I am not sure what method you are using to Add New record. This how it works:

Assumption:
You are using a DataTable and DataAdapter

- When you about the Add a record, the autonumber field will use a negative value (which is not insert into the database yet).
- Once you add new, DB will generate a position number as ID. But it will not get updated on the DataTable unless or until you select the table again.
 
Share this answer
 
Comments
saeid.piran 23-May-11 0:40am    
thank you
Venkatesh Mookkan 23-May-11 0:41am    
Thank you for marking it as 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