Export (0) Print
Expand All

DataColumn.AutoIncrementStep Property

Gets or sets the increment used by a column with its AutoIncrement property set to true.

[Visual Basic]
Public Property AutoIncrementStep As Long
[C#]
public long AutoIncrementStep {get; set;}
[C++]
public: __property __int64 get_AutoIncrementStep();
public: __property void set_AutoIncrementStep(__int64);
[JScript]
public function get AutoIncrementStep() : long;
public function set AutoIncrementStep(long);

Property Value

The number by which the value of the column is automatically incremented. The default is 1.

Exceptions

Exception Type Condition
ArgumentException The value set is zero.

Example

[Visual Basic, C#, C++] The following example sets the AutoIncrement, AutoIncrementSeed, and AutoIncrementStep properties.

[Visual Basic] 
Private Sub AddAutoIncrementColumn()
    Dim myColumn As DataColumn = New DataColumn
    myColumn.DataType = System.Type.GetType("System.Int32")
    With MyColumn
       .AutoIncrement = True
       .AutoIncrementSeed = 1000
       .AutoIncrementStep = 10
    End With
    ' Add the column to a new DataTable.
    Dim myTable As DataTable
    myTable = New DataTable
    myTable.Columns.Add(myColumn)
 End Sub

[C#] 
private void AddAutoIncrementColumn(){
    DataColumn myColumn = new DataColumn();
    myColumn.DataType = System.Type.GetType("System.Int32");
    myColumn.AutoIncrement = true;
    myColumn.AutoIncrementSeed = 1000;
    myColumn.AutoIncrementStep = 10;
    // Add the column to a new DataTable.
    DataTable myTable = new DataTable("MyTable");
    myTable.Columns.Add(myColumn);
 }

[C++] 
private:
void AddAutoIncrementColumn(){
    DataColumn* myColumn = new DataColumn();
    myColumn->DataType = System::Type::GetType(S"System.Int32");
    myColumn->AutoIncrement = true;
    myColumn->AutoIncrementSeed = 1000;
    myColumn->AutoIncrementStep = 10;
    // Add the column to a new DataTable.
    DataTable* myTable = new DataTable(S"MyTable");
    myTable->Columns->Add(myColumn);
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataColumn Class | DataColumn Members | System.Data Namespace | AutoIncrement | AutoIncrementSeed | Expression | ItemArray

Show:
© 2014 Microsoft