I've set up a SQL Server Compact 3.5 database in my WinForm application. I set my ID identity to true so that when the user adds to the database it will automatically give it an ID and automatically increment it. However, for some reason after the first item is entered into the database the ID goes to -1 and then -2, -3, etc. How come it doesn't increment correctly? Did I set it up incorrectly?
Update:
Another Update: I ran the application and added 4 things to the database, closed the application and opened it again. When I did this all the id's were suddenly correct. It's like the id is only incorrect when when it's first added, but when the database is reloaded it's correct. Hopefully that made sense.
编辑您的表模式,并设置Identity Increment = 1
和Identity Seed = 1
的性能identity
列。
Found the solution in this thread:
Based on the information provided in that thread this occurs because I'm using a DataSet and a DataAdapter in my application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.