Add Autonumber field

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I am trying to programatically add a table to an existing
Access database. I can create the table exactly as I need
to except for one problem. One of the fields in the new
table has to be an autonumber and I cannot seem to do this.

The usual create table command would be something like:

"CREATE TABLE TABLE1 (Field1 Number, Field2 Text (255))"

What if Field1 has to be an autonumber? Instead of number
I have tried "Autonumber" and a bunch of other pure
guesses to no avail.

Anyone know how to do this?
 
I'm not sure if you mean do this repeatedly and define it
in the actual access table, or in the local datatable. If
it's latter, try this...
DataColumn workColumn = workTable.Columns.Add
("CustomerID", typeof(Int32));
workColumn.AutoIncrement = true;
workColumn.AutoIncrementSeed = 200;
workColumn.AutoIncrementStep = 3;
 
Back
Top