简体   繁体   中英

“Cannot open a database created with a previous version of your application” shows when VB.NET program tried to open a MDB file using OleDBConnection

I have created a software using VB.NET in a 32-bit Windows 7 OS.

It contains those line of codes below:

 Dim cn As New OleDbConnection
 cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & fileNameStr & ";Jet OLEDB:Database Password=xxxxxxx"
 cn.Open()

The codes open a MDB file (Microsoft Access file) protected by a password.

When I run the software in my computer, it works well.

However, when it is tested in another computer, an error message appears saying "Cannot open a database created with a previous version of your application."

The error message is shown after the third line of code. 在此处输入图片说明

Could you suggest where my mistakes are and how do I resolve the problem.

Thank you.

When I run the software in my computer, it works well.

However, when it is tested in another computer, an error message appears saying "Cannot open a database created with a previous version of your application."

This can happen when the different machines have different versions of the Access Database Engine installed. Specifically, the error message will appear if

  • the .mdb file is in Access 97 format, and
  • the machine has the Access 2013 (or later) version of the Access Database Engine.

Access 2013 removed support for the Access 97 file format.

This can be slightly confusing if your connection string contains

Provider=Microsoft.ACE.OLEDB.12.0

because the Access 2007 (12.0), Access 2010 (14.0), and Access 2013 (15.0) versions of the Access Database Engine all register the provider under the "12.0" name to offer some degree of backward compatibility. So for any given machine with Access 2007+ on it you may specify

Microsoft.ACE.OLEDB.12.0

but what you are actually using is

Microsoft.ACE.OLEDB.12.0 on an Access 2007 machine
Microsoft.ACE.OLEDB.14.0 on an Access 2010 machine
Microsoft.ACE.OLEDB.15.0 on an Access 2013 machine

That is why the same third-party application can open an .mdb file on one machine (with Access 2007 or 2010 installed) but not on another machine (with Access 2013 installed).

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