vba 通过运行宏通过 Excel 连接到 MySQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5349947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting to MySQL through Excel by running a Macro
提问by Parth Bhatt
strSQL = "INSERT INTO [ODBC;DSN=DSNName;].NameOfMySQLTable (IndexCode,LastTradePrice) VALUES"
strSQL = strSQL & "Select F1,G1 As NameOfMySQLField FROM [Excel 8.0;DATABASE=" & strFile & ";HDR=NO;IMEX=1].[Sheet1$];"
This is the query I write in MS Excel's macro. I have a database on server where I want this values to get inserted.
这是我在 MS Excel 的宏中编写的查询。我在服务器上有一个数据库,我希望在其中插入这些值。
What is to be written in place of [ODBC;DSN=DSNName;].NameOfMySQLTable
and in place of NameOfMySQLField
?
用什么来代替[ODBC;DSN=DSNName;].NameOfMySQLTable
和代替NameOfMySQLField
?
采纳答案by Mohamed Saligh
You can find something here useful:
你可以在这里找到有用的东西:
http://www.heritage-tech.net/908/inserting-data-into-mysql-from-excel-using-vba/
http://www.heritage-tech.net/908/inserting-data-into-mysql-from-excel-using-vba/