大佬教程收集整理的这篇文章主要介绍了Excel VBA:写入mysql数据库,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以使用连接字符串和ADO连接到MysqL:
''http://support.microsoft.com/kb/246335
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
strCon = "Driver={MysqL ODBC 3.51 Driver};Server=localhost;Database=MyDB;" _
& "User=root;password=pw;Option=3;"
cn.open strCon
您还可以使用jet驱动程序将DSN与Excel连接使用:
Dim cn As ADODB.Connection
''Not the best way to get the name, just convenIEnt for notes
strfile = Workbooks(1).Fullname
strCon = "ProvIDer=Microsoft.jet.olEDB.4.0;Data source=" & strfile _
& ";Extended PropertIEs=""Excel 8.0;HDR=Yes;IMEX=1"";"
Set cn = CreateObject("ADODB.Connection")
''For this to work, you must create a DSN and use the name in place of
''DSNname
strsql = "INSERT INTO [ODBc;DSN=DSNname;].nameOfMysqLtable " _
& "SELEct AnyFIEld As nameOfMysqLFIEld FROM [Sheet1$];"
cn.Execute strsql
我想在Excel中编写一个宏,该宏将写入mysql数据库。有人可以帮我开始这个吗?
以上是大佬教程为你收集整理的Excel VBA:写入mysql数据库全部内容,希望文章能够帮你解决Excel VBA:写入mysql数据库所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。