How to: Create an Autonumber DataColumn
Data columns () often contain auto-generated sequential numbers; for example, primary keys and ID columns. You can load auto-generated numbers in data columns by setting the , , and properties of the data column.
When data columns are created by means of Visual Studio design tools, the columns are automatically marked as AutoIncrement. When you update a table in the database that contains an Identity column, the values created with the auto-numbering feature are not sent to the database.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see.
To set a data column to contain auto-generated numbers
Open your dataset in the Dataset Designer.
Select the column you want to populate with auto-generated numbers.
In the Properties window, set the following properties:
If you want to begin at a number different from the default value of 0, set this value to the starting number for this column.
In each new row, the column value is incremented by this value.
Setting a data column to auto-increment does not automatically designate the column as a primary key. To set a data column as a primary key column, see.