hello,
i'm creating tables in an access database via ADOX.
i can create the tables, add fields to it (eg. integer, varchar, ...) , but now i want an autonumbering field.
how can i do this?
Printable View
hello,
i'm creating tables in an access database via ADOX.
i can create the tables, add fields to it (eg. integer, varchar, ...) , but now i want an autonumbering field.
how can i do this?
' Create a new autonumber ID Column
Set col = New ADOX.Column
col.Name = "theColName"
col.Type = adInteger
col.ParentCatalog = cat 'cat is the catalog variable
col.Properties("Autoincrement") = True
cat.Tables("theTableName").Columns.Append col
or u can use SQL ...
VB Code:
SQL = "ALTER TABLE Table1 ADD COLUMN ID COUNTER" cnn.Execute SQL
thanks.