MySQL to MS Access

∥☆過路亽.° 提交于 2020-01-07 02:17:33

问题


For some time we've been retrieving data from a remote MS Access database and copy its contents to a local Access DB with a simple SELECT * INTO query. However we're currently in a migration process which requires to retrieve data from the MySQL database and copy it to the local Access DB, thus the aforementioned query won't work here for obvious reasons.

Now seeing as I can't use any external programs and are only allowed to write in VB.NET, my method to transfer the data over is by using datatables. It does its job, but the performance is dreadful.

My questions therefore is, is there a fast way to transfer/copy data from the remote MySQL database to a local MS Access with only using VB.NET.

My current code: pastebin.com/ELmkVFSc


回答1:


Very roughly:

Imports Microsoft.Office.Interop.Access.Dao

Module Module1

    Sub Main()
        Dim dbEng As New DBEngine()
        Dim ws As Workspace
        Dim db As Database
        ws = dbEng.CreateWorkspace("", "admin", "", WorkspaceTypeEnum.dbUseJet)
        db = ws.OpenDatabase("z:\\docs\\test.accdb", False, False, "")
        db.Execute("SELECT * INTO Newtable From [ODBC;DSN=MySQL;].test")

    End Sub

End Module

You could also have a query on these lines:

SELECT * INTO Newtable FROM
[ODBC;Driver={MySQL ODBC 5.1 Driver};Server=127.0.0.1;Database=test;User=usr;Password=pwd;CLIENT_MULTI_RESULTS;Option=3;].test;


来源:https://stackoverflow.com/questions/12591809/mysql-to-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!