I use DAO to attach Pervasive tables to Access in the following way:
Dim db As DAO.Database
Dim td As DAO.TableDef
Set db = DAO.OpenDatabase(strDB)
Set td = db.CreateTableDef("MyTable")
td.Connect = "ODBC;DSN=SAMPLE"
td.SourceTableName = "Table"
db.TableDefs.Append td
So when you open the Access db you will see the table attached as MyTable.
I am trying to do the same using ADO, but I just seem to be getting nowhere.
Here's what I have in ADO:
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
catDB.ActiveConnection = "Provider=PervasiveOLEDB;Data Source=SAMPLE;Persist Security Info=False"
Set tblLink = New ADOX.Table
With tblLink
.Name = "MyTable"
Set .ParentCatalog = catDB
End With
catDB.Tables.Append tblLink
At this point I get an error: "Table MyTable already exists".
Another thing I cannot figure out is where to specify the source table name.
Dim db As DAO.Database
Dim td As DAO.TableDef
Set db = DAO.OpenDatabase(strDB)
Set td = db.CreateTableDef("MyTable")
td.Connect = "ODBC;DSN=SAMPLE"
td.SourceTableName = "Table"
db.TableDefs.Append td
So when you open the Access db you will see the table attached as MyTable.
I am trying to do the same using ADO, but I just seem to be getting nowhere.
Here's what I have in ADO:
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
catDB.ActiveConnection = "Provider=PervasiveOLEDB;Data Source=SAMPLE;Persist Security Info=False"
Set tblLink = New ADOX.Table
With tblLink
.Name = "MyTable"
Set .ParentCatalog = catDB
End With
catDB.Tables.Append tblLink
At this point I get an error: "Table MyTable already exists".
Another thing I cannot figure out is where to specify the source table name.