Sancho Almeda
Sancho Almeda

Reputation: 151

VB6 - Inserting a data to an Access Table from a mySQL Table

I have a desktop application created via VB6 using Access Database and MySQL

The application is deployed in client computers without MS Access.

The MS Access Database and MySQL Database have the same tables.

What I want to do is copy the table data from MySQL Database into the Access Table using the VB6 Application. I was thinking of using something like this:

INSERT INTO Target (ID, Value)
SELECT ID, Value
FROM Source WHERE NOT EXISTS (SELECT * FROM Target WHERE Target.ID = Source.ID)

Is this possible?

Upvotes: 3

Views: 533

Answers (1)

Erik A
Erik A

Reputation: 32642

Yes, you can directly query ODBC data sources from Access:

INSERT INTO Target (ID, Value)
SELECT ID, Value
FROM [ODBC;Driver={MySQL ODBC 5.2 UNICODE Driver};Server=myServer;Database=myDataBase;
User=myUsername;Password=myPassword;].Source 
WHERE NOT EXISTS (SELECT * FROM Target WHERE Target.ID = Source.ID)

You need to execute this query on the Access database (I recommend doing it using DAO), and then that will connect and load the data from MySQL.

Upvotes: 3

Related Questions