Hi,
Does anyone know a way, to create a ID field in a access database with the Autoincrement enabled thru code?
I been trying with this code :
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, _
objTable As ADOX.Table
Cn = New ADODB.Connection
Cat = New ADOX.Catalog
objTable = New ADOX.Table
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Databasesti)
Cat.ActiveConnection = Cn
objTable.Name = "PcOversigt"
objTable.Columns.Append("Id", DataTypeEnum.adInteger)
With objTable.Columns("Id")
.Properties("AutoIncrement").Value = True
End With
objTable.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary, "Id")
Cat.Tables.Append(objTable)
Googling didnt help and i didnt seem to find any subject in tek-tips which could help
Does anyone know a way, to create a ID field in a access database with the Autoincrement enabled thru code?
I been trying with this code :
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, _
objTable As ADOX.Table
Cn = New ADODB.Connection
Cat = New ADOX.Catalog
objTable = New ADOX.Table
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Databasesti)
Cat.ActiveConnection = Cn
objTable.Name = "PcOversigt"
objTable.Columns.Append("Id", DataTypeEnum.adInteger)
With objTable.Columns("Id")
.Properties("AutoIncrement").Value = True
End With
objTable.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary, "Id")
Cat.Tables.Append(objTable)
Googling didnt help and i didnt seem to find any subject in tek-tips which could help