简体   繁体   English

VB6 - 从mySQL表中将数据插入访问表

[英]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 我有一个使用Access数据库和MySQL通过VB6创建的桌面应用程序

The application is deployed in client computers without MS Access. 该应用程序部署在没有MS Access的客户端计算机中。

The MS Access Database and MySQL Database have the same tables. MS Access数据库和MySQL数据库具有相同的表。

What I want to do is copy the table data from MySQL Database into the Access Table using the VB6 Application. 我想要做的是使用VB6应用程序将表数据从MySQL数据库复制到访问表中。 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? 这可能吗?

Yes, you can directly query ODBC data sources from Access: 是的,您可以直接从Access查询ODBC数据源:

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. 您需要在Access数据库上执行此查询(我建议使用DAO执行此操作),然后将连接并从MySQL加载数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM