المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Retreiving next autonumber value



C# Programming
01-17-2010, 11:31 PM
I have written a program that uses the ID field in an access database. If the user removes an item the autonumber still increments by one. That is fine but my question is this.

How does one retrieve the value of the next autonumber when the add new item button is pressed on the bindingnavigation bar?

I originally was doing
int rowcount = this.bookdbDataSet.Tables[0].Rows.Count +1;

this works but it shows me the true value of records in the table. I don't want that I want to know what the next autonumber ID would be.

Example: I have filtered using a search for say cat
I get 2 records back the navigation bar says 1 of 2. And that listings Item ID: 1. I then discover that I wish to add another record so I hit the add button. I would to autofile the Item ID box with the next autonumber in the IDcolumn of the database.

I hope I'm not confusing anyone. Your help is greatly appreciated.