vba 运行时错误“3706”:找不到提供程序 -Visual Basic
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20278862/
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
Run time error '3706': Provider cannot be found -Visual Basic
提问by Kentot
I am trying to connect Visual Basic to MS Access using ADODB. But as I execute my code, it prompts: "Provider cannot be found.It may not be installed properly." But when I check on my directory I've got my "msjetoledb40.dll" installed.
我正在尝试使用 ADODB 将 Visual Basic 连接到 MS Access。但是当我执行我的代码时,它提示:“找不到提供程序。它可能没有正确安装。” 但是当我检查我的目录时,我已经安装了我的“msjetoledb40.dll”。
Here is my code:
这是我的代码:
Dim conn As ADODB.Connection, rec As ADODB.Recordset
Sub sample()
Set conn = New ADODB.Connection
conn.Open ("Provider=Microsoft.Jet.OLEDB 4.0;Data Source=C:\sample.mdb;Persist Security Info=false;")
End Sub
回答by jacouh
This would be better:
这样会更好:
Sub sample()
Dim conn As ADODB.Connection, rec As ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\sample.mdb;"
conn.Open
End Sub
You missed a point.
你错过了一个点。
Microsoft.Jet.OLEDB 4.0 => Microsoft.Jet.OLEDB.4.0
Microsoft.Jet.OLEDB 4.0 => Microsoft.Jet.OLEDB.4.0
回答by Sheng Huang
Confirming the version of your MS Office on which the script is running. If you have installed MS Office 2013 or later, you should revise the connection string from:
确认运行脚本的 MS Office 版本。如果您安装了 MS Office 2013 或更高版本,则应从以下位置修改连接字符串:
Provider=Microsoft.Jet.OLEDB 4.0;Data Source=C:\sample.mdb;Persist Security Info=false;
to:
到:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\sample.mdb;Persist Security Info=false;
At least, this sovled my problem.
至少,这解决了我的问题。
回答by Luis
My solution:
我的解决方案:
Error 3706
错误 3706
cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sPath & ";Persist Security Info=False;"
Just Change 12.0 for 15.0
只需将 12.0 更改为 15.0
cs = "Provider=Microsoft.ACE.OLEDB.15.0;Data Source=" & sPath & ";Persist Security Info=False;"
and works, always you must to try change the version of the controller!.
并且有效,您必须始终尝试更改控制器的版本!。