ADOX Add Column Multi-Step OLE DB errors
Posted on 2007-07-31
I am trying to add a column to an Access DB table using ADOX. The column s/b an Autonumber-ReplicationID that autogenerates new values when records are added.
Here is my code:
Dim tbl As ADOX.Table
Dim col As New ADOX.Column
Dim cat As New ADOX.Catalog
Dim cnn As New ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & sDBPath & ";"
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = cnn
Set tbl = cat.Tables(sTblName)
Set col = New ADOX.Column
.Name = sColName
.Type = adGUID
.ParentCatalog = cat
Everything works fine up to this point.
When the next line executes, I receive a -2147217887 Multiple-step OLD DB operation generated errors.
col.Properties("jet oledb:autogenerate").Value = True
This actually happens no matter what datatype I try to append or what Property I'm trying to set.
I've seen multiple examples of this same code all over the internet, but can't seem to get it to work.
Any help is greatly appreciated.