简体   繁体   English

VB6和Access 2007连接问题

[英]VB6 & Access 2007 connection problems

OK, so I've read this identical question, but the answers don't work for me: 好的,所以我读了这个相同的问题,但是答案对我不起作用:

Connecting VB6 and MS Access 2007 连接VB6和MS Access 2007

I've removed the reference to Microsoft DAO 3.6 Object Library , and replaced it with a reference to Microsoft Office 12.0 Access database engine Object . 我已经删除了对Microsoft DAO 3.6对象库的引用,并将其替换为对Microsoft Office 12.0 Access数据库引擎对象的引用。

Here's my code: 这是我的代码:

Dim rcdSetData As ADODB.Recordset

Set rcdSetData = New ADODB.Recordset
rcdSetData.CursorType = adOpenStatic
rcdSetData.ActiveConnection = _
    "Provider=Microsoft.Jet.OLEDB.4.0; " _
    & "Data Source=" & DBName & "; "

I can open Access 2003 *.mdb files just fine, but when I try to open an Access 2007 *.accdb file, I get: 我可以很好地打开Access 2003 * .mdb文件,但是当我尝试打开Access 2007 * .accdb文件时,我得到了:

Error #blahblah, Unrecognized database format 'C:\path\foo.accdb'

foo.accdb is a valid Access 2007 file, as far as Access 2007 cares. 就Access 2007而言,foo.accdb是有效的Access 2007文件。 No password, BTW, and it isn't open in Access when I run the program. 没有密码,顺便说一句,当我运行该程序时,它没有在Access中打开。

I'm stumped. 我很沮丧 EVERY answer I can find on the web says I'm doing this right.... :\\ 我在网上找到的每个答案都说我做对了。...:\\

The DAO reference (be it to the pre- or post-Access 2007 version of that library) is irrelevant, since your VB code is using ADO instead. DAO参考(对于该库的Access 2007之前或之后版本)无关紧要,因为您的VB代码改用ADO。 Your problem lies rather with the connection string. 您的问题在于连接字符串。 Try replacing 尝试更换

"Provider=Microsoft.Jet.OLEDB.4.0; " _

with

"Provider=Microsoft.ACE.OLEDB.12.0; " _

如果您最近重新安装了VB6,请确保为其下载并安装Service Pack SP6。

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

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