hunterex
hunterex

Reputation: 595

"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. enter image description here

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

Thank you.

Upvotes: 2

Views: 7880

Answers (2)

BillH
BillH

Reputation: 46

I was trying to open a *.mdb that was saved in 2006. I tried various things, but using SQL Server Management Studio 18.9.2 (SSMS) to import the data was the way that worked for me. Here's what I did (assumes you have access to SQL Server and a database there):

  • Right click on a database where you want the imported table(s) to go
  • Select Tasks -> Import Data
  • For Data Source select Microsoft Access (Microsoft Jet Database Engine)
  • File Name - Browse to the *.mdb file and select it and click open
  • Click Next
  • Destination: SQL Server Native Client 11.0
  • Select the server name (this may already be set correctly)
  • Set up whatever authentication your Server needs in the Authentication box
  • Make sure the correct Database is selected in the database dropdown (may already be correct)
  • Click next
  • Leave the setting "Copy the data from one or more tables or views"
  • Click next
  • Select the table(s) you want to import
  • click next
  • click next
  • click finish That did it for me. Once you have it in SQL Server you can manipulate it as you need.

Upvotes: 1

Gord Thompson
Gord Thompson

Reputation: 123549

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

Upvotes: 3

Related Questions