Using Custom Auto-Increment Logic
The AutoIncrementCustom, AutoIncrementSeed, and AutoIncrementStep business object properties provide finer control over ADO.NET's auto-incrementing logic.
If AutoIncrementCustom is true, the business object provides custom auto-increment values when adding new rows to a DataSet. The AutoIncrementSeed property specifies the starting value of auto-increment columns, and AutoIncrementStep specifies the increment step.
This custom auto-incrementing logic is desirable when adding new rows to a DataSet that contains existing data. By default, ADO.NET automatically assigns a new row's primary key a temporary value of the highest primary key in the DataSet plus one (1). For example, if the primary key of an Orders DataSet is the Order Number, and a DataSet contains the following orders:
100401
100503
100602
when you add a new record to the DataSet, ADO.NET assigns an order number of 100603.
In contrast, if you set the business object's AutoIncrementCustom property to true, by default, the new order number is -1, and the next order number is -2, and so on. This is because the default value of AutoIncrementSeed is -1, and the default value of AutoIncrementStep is -1.
Note: If you are using custom data access classes, and you have specified that DataSets should be refreshed (the default setting) you don't need to use this feature, because when you add a new DataRow, the new primary key is automatically retrieved from the database and placed in the new DataRow.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/12/26
Comment or report problem with topic
