Hanging connection with ADOX and .mdb
When I try to create a table with ADOX, I end up with a hanging connection.
I'm not sure if that's the right term, but what I mean is the record locking
file (.ldb) remains after the code has finished executing. I am setting all
the objects to Nothing and there is no Close method for a ADOX.Catalog object.
Has anyone seen this before or knows what I'm doing wrong? This is the code
I'm using (roughly simplified) and Access 97 is installed.
Public Sub CreateDB(dbPathName As String)
Dim Cat As New ADOX.Catalog, Table As ADOX.Table, Indx As ADOX.Index
Cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbPathName & ";Jet OLEDB:Engine Type=4;"
Set Table = New ADOX.Table
Table.Name = TableName
For X = LBound(Fields) To UBound(Fields)
Table.Columns.Append [FieldName], [FieldType], [FieldSize]
Set Table.Columns([FieldName]).ParentCatalog = Cat
Table.Columns([FieldName]).Properties("AutoIncrement") = [Whatever]
Table.Columns([FieldName]).Properties("Jet OLEDB:Allow Zero Length") = [Whatever]
For X = LBound(Indexes) To UBound(Indexes)
Set Indx = New ADOX.Index
Indx.Name = [IndexName]
Indx.Unique = [Whatever]
Indx.PrimaryKey = [Whatever]
Set Indx = Nothing
Set Table = Nothing
Set Cat = Nothing
I would think that setting the Catalog object to nothing would close the
connection, but I don't know, it doesn't seem to work.
Any help at all would be great. Thanks.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center