简体   繁体   English

将 mysql 表导出到 ms Access 表中的最快/安全方式

[英]fastest/secure way for export mysql tables into ms Access table

i'm searching for a way to export some MySql tables into other tables of a MsAccess DB (I'm talking about a million records table...)我正在寻找一种将一些 MySql 表导出到 MsAccess DB 的其他表中的方法(我说的是一百万条记录表......)

the only two way that I thought about are:我想到的唯一两种方法是:

  1. export from myadmin or toad a csv file and then import it into the access DB.从 myadmin 或 toad 导出 csv 文件,然后将其导入访问数据库。

  2. making directly from Toad the "Access Database Export"直接从 Toad 制作“Access 数据库导出”

I'm getting that the first is more fast but less secure for the data integrity, while the second is perfect for the data integrity but very slow... someone knows other ways?我知道第一个速度更快但数据完整性不太安全,而第二个非常适合数据完整性但速度很慢......有人知道其他方式吗?

Thanks A.谢谢。

step by step guide to running Access frontend application with MySQL database on webserver (you dont need to IMPORT the tables, you can use your msaccess application WITH them on the webserver):在网络服务器上使用 MySQL 数据库运行 Access 前端应用程序的分步指南(您不需要导入表,您可以在网络服务器上使用您的 msaccess 应用程序):

If you are running MsAccess, i suppose that you are using windows如果您正在运行 MsAccess,我想您正在使用 windows

  1. Install MySQL ODBC 5.1 Driver (connector) http://dev.mysql.com/downloads/connector/odbc/安装 MySQL ODBC 5.1 驱动程序(连接器)
  2. Open CONTROL PANEL on win machine在win机器上打开控制面板
  3. ADMINISTRATIVE TOOLS (if Vista or Seven, search ODBC)管理工具(如果是 Vista 或 7,请搜索 ODBC)
  4. SET UP DATA SOURCES ODBC设置数据源 ODBC
  5. SYSTEM DSN系统DSN
  6. ADD添加

depending on your server, you might have some difficulty finding the server name or IP, look for SSH Database connection (or something like that).根据您的服务器,您可能很难找到服务器名称或 IP,查找 SSH 数据库连接(或类似名称)。 as an example, read NetSol's FAQ: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/例如,阅读 NetSol 的常见问题解答: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/

once you have done that, in MsAccess: 1. FILES 2. EXTERNAL DATA SOURCE 3. LINK TABLES完成此操作后,在 MsAccess 中: 1. 文件 2. 外部数据源 3. 链接表

if you want to EXPORT to MySQL from MsAccess, you can create a FORM in access, put a button on it, and in VBA create this sub for the OnClick() event:如果您想从 MsAccess 导出到 MySQL,您可以在 access 中创建一个 FORM,在其上放置一个按钮,然后在 VBA 中为 OnClick() 事件创建此子:

Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls

sometimes, while running non-english windows you might get error 2507, change "ODBC Database" for "ODBC" (works with French).有时,在运行非英语 windows 时,您可能会收到错误 2507,将“ODBC 数据库”更改为“ODBC”(适用于法语)。

If you have ODBC access to MySQL, and your server is on your network, you can import its tables from within Access.如果您对 MySQL 具有 ODBC 访问权限,并且您的服务器在您的网络上,则可以从 Access 中导入其表。 I think the menu selections are "File | Get external data | Import".我认为菜单选择是“文件|获取外部数据|导入”。

For "Files of type", select "ODBC Databases".对于“文件类型”,select“ODBC 数据库”。 You might need to create a new DSN name.您可能需要创建一个新的 DSN 名称。

I can't recall whether ODBC drivers are generally an installation default, or whether they're a separate install.我不记得 ODBC 驱动程序通常是默认安装还是单独安装。 I think they're installed by default, but I could be wrong.我认为它们是默认安装的,但我可能是错的。

Thanks tony for that awesome time-saving script.感谢 Tony 提供了一个很棒的省时脚本。 Since I name my tables with the prefix "tbl", I modified the code so it will only export those tables (not the weird looking ones):因为我用前缀“tbl”命名我的表,所以我修改了代码,所以它只会导出那些表(而不是那些看起来很奇怪的表):

Private Sub Command0_Click()
Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef
Dim str As String

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=proxmox decaoriginal;UID=matantan;PWD=majadero5"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

str = "tbl"

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
If Left(tbldef.Name, 3) = str Then
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Else
End If
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure  ExportTblsODST"
Resume SmoothExit_ExportTbls
End Sub

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

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