Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to attach Pervasive tables to Access database

Status
Not open for further replies.

ettienne

Programmer
Oct 29, 2005
3,388
US
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.
 
Is the code being run in Access or VB? Have you tried changing the following line:
Code:
catDB.ActiveConnection = "Provider=PervasiveOLEDB;Data Source=SAMPLE;Persist Security Info=False"
to
Code:
catDB.ActiveConnection = "DSN=SAMPLE"


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
The code is run in VB.

I will give the change a shot, maybe I am too focussed on Pervasive.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top