Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net add primary key identity column to datatable

HI

I am using the following VB.net code to add an identity column. How do I set it as the primary key too?

            Dim dtNew As New DataTable()
            'Add columns to DataTable.
            '------------ ID Column -------------
            dtNew.Columns.Add("ID")
            'Set AutoIncrement True for the First Column.
            dtNew.Columns("ID").AutoIncrement = True
            'Set the Starting or Seed value.
            dtNew.Columns("ID").AutoIncrementSeed = 1

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thank you very much