views:

10

answers:

1

I have an access database table that has an autoNumber column, and the table is connected to a winform through a dataGridView. Now every time I add a new row, the autonumber column cell of the new row is set to -1,-2,-3...etc instead of 28,29...etc how can I fix this. Using Visual c#2008 express on XP.

A: 

Are you storing this in SQL Server in the end? The real auto-number will only ever be determined when you actually store the data to the table.

Therefore, while you're editing in memory without storing yet, the GridView will use the negative numbers as autonumbers. When you actually send those rows to SQL Server and store them, they'll get their real autonumbers 28, 29, 30 etc., and the references to those values will be updated.

Try it! After saving, you'll have the "right" auto-numbers, I'm sure.

marc_s
Oh man do I feel stupid right now. You're right they did get the right numbering, all I had to do was save and refresh. Thanks a lot for the help.
meevo