vba 连接DAO访问时出现429错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28386307/
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
Error 429 when connect DAO Access
提问by Braulio
I have the follow VBA code which I use to connect to a MDB data base but I am getting a 429 error when I try to connect DAO.OpenDatabase(DbFile)
我有以下 VBA 代码,用于连接到 MDB 数据库,但是当我尝试连接 DAO.OpenDatabase(DbFile) 时出现 429 错误
I was not getting this error before but now it is happening. On my other computer this connection works fine.
我以前没有收到此错误,但现在正在发生。在我的另一台计算机上,此连接工作正常。
I checked the path of MDB and it is correct.
我检查了MDB的路径,它是正确的。
The references I am using are:
- Visual Basic for Applications
- Microsoft Excel 15.0 Object Library
- OLE Automation
- Microsoft Office 15.0 Object Library
- Microsoft DAO 3.6 Object Library
我使用的参考是:
- Visual Basic for Applications
- Microsoft Excel 15.0 对象库
- OLE 自动化
- Microsoft Office 15.0 对象库
- Microsoft DAO 3.6 对象库
I am using Excel 2013 (in other computer is Excel 2010) but as I said it was working before on 2013.
我正在使用 Excel 2013(在其他计算机中是 Excel 2010),但正如我所说,它在 2013 年之前就可以使用了。
Does anyone knows how to get this problem solved, please?
请问有人知道如何解决这个问题吗?
Private Sub IniciaDB()
Dim rs As Recordset
Dim fld As Variant
Dim DbFile as String
DbFile = "D:\Documentos\PMbox\PPMdatabase2.MDB"
On Error Resume Next
Set OpenConn = DAO.OpenDatabase(DbFile)
If Err.Number = 3024 Then MsgBox "Check connection string in the VBA StaticClass object", vbOKOnly
Set ObjAccess = CreateObject("Access.Application")
ObjAccess.Visible = False
ObjAccess.OpenCurrentDatabase (DbFile)
'runSQL ("INSERT INTO tabela_teste VALUES ('My name', 34)")
Set rs = runCursorSQL("SELECT * FROM tabela_teste")
Do While Not rs.EOF
For Each fld In rs.Fields
Debug.Print fld.Value & ";";
Next
rs.MoveNext
Loop
closeResources
End Sub
回答by Jiri Tersel
I had been struggling with the same issue for quite a long time.
It turned out that my Office was 64bitand so the referenced Microsoft DAO 3.6 Object Librarydidn't work.
很长一段时间以来,我一直在为同样的问题苦苦挣扎。
结果发现我的 Office 是64 位的,因此引用的Microsoft DAO 3.6 对象库不起作用。
Playing around with the references, it turned out that using Microsoft Office 15.0 Access database engine Object(ACEDAO.DLL)instead of the DAO360solved the issue.
查阅参考资料后发现,使用Microsoft Office 15.0 Access 数据库引擎对象(ACEDAO.DLL)而不是DAO360解决了该问题。
Link to a similar answer that would have solved my issue if I found it sooner Writing Excel VBA to receive data from Access
链接到一个类似的答案,如果我早点发现它可以解决我的问题编写 Excel VBA 以从 Access 接收数据
回答by Harvard
I was building a MDB to ACCDB converter when I ran into the Error 429. Here is a link to the download that solved my problem.
当我遇到错误 429 时,我正在构建一个 MDB 到 ACCDB 转换器。这是解决我的问题的下载链接。
http://www.microsoft.com/en-ca/download/details.aspx?id=13255
http://www.microsoft.com/en-ca/download/details.aspx?id=13255
Quote: "This download will install a set of components that can be used to facilitate transfer of data between 2010 Microsoft Office System files and non-Microsoft Office applications."
引用:“此下载将安装一组组件,可用于促进 2010 Microsoft Office System 文件和非 Microsoft Office 应用程序之间的数据传输。”
回答by Darkseal
I spent a night over this problem, until I finally fixed it by uninstalling the 64-bit versions of both MS Office and MS Access 2010 Redistributable and then re-installing the 32-bit version of both of them.
我花了一个晚上来解决这个问题,直到我通过卸载 MS Office 和 MS Access 2010 Redistributable 的 64 位版本,然后重新安装它们的 32 位版本,最终解决了这个问题。
It definitely seems to me that the 64-bit builds have compatibility issues with this use of DAO.
在我看来,64 位版本在使用 DAO 时确实存在兼容性问题。
I described the whole issue I had in this blog post.
我在这篇博文中描述了我遇到的整个问题。
回答by Braulio
Well, the solution found is that the DAO reference was missing, it is in my computer but the reference indicates to Program Files and DAO is actually on Program Files (x86)
好吧,找到的解决方案是缺少 DAO 引用,它在我的计算机中,但引用指示 Program Files 而 DAO 实际上在 Program Files (x86) 上