Export (0) Print
Expand All
1 out of 5 rated this helpful - Rate this topic

How to: Create an Autonumber DataColumn 

Data columns (DataColumn) 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 AutoIncrement, AutoIncrementSeed, and AutoIncrementStep 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.

NoteNote

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 Visual Studio Settings.

To set a data column to contain auto-generated numbers

  1. Open your dataset in the Dataset Designer.

  2. Select the column you want to populate with auto-generated numbers.

  3. In the Properties window, set the following properties:

    Property Setting

    AutoIncrement

    true

    AutoIncrementSeed

    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.

    AutoIncrementStep

    In each new row, the column value is incremented by this value.

    NoteNote

    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 How to: Set a Data Column as the Primary Key.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.