简体   繁体   中英

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

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 .

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:

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

foo.accdb is a valid Access 2007 file, as far as Access 2007 cares. No password, BTW, and it isn't open in Access when I run the program.

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. 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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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