Question about creating Access tables in VB.Net using ADOX

G

Guest

I'm writing a VB.Net program. At startup the program looks for a default
Access mdb and if it isn't there, creates it. At least that's the design.

My question is this: Using ADOX, is there anyway to declare an
AutoIncrement table field? I don't see anything in the DataTypeEnum that
seems equivalent.

Dim tbl As New Table
tbl.Name = "Table1"
tbl.Columns.Append("Field1", ??????? )
 
C

CT

You need to use the DataTypeEnum.adInteger and then set the AutoIncrement
property;

Dim tbl As New Table
Dim col as New Column
tbl.Name = "Table1"
col.Name = "Field1"
col.Type = DataTypeEnum.adInteger
' Add column to the catalog
col.ParentCatalog = catalog ' Of type ADOX.Catalog
col.Properties("Autoincrement") = True
tbl.Columns.Append(col)
 
G

Guest

Thanks! That would have been my next step, if I couldn't get ADOX to
cooperate. I am not that used to creating DBs programmatically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top