Access DAO throws COMException for Access 97 files

Viewed 130

We are using Microsoft.Office.Interop.Access.Dao (version 15.0.0.0) library for accessing information in Microsoft Access files, because it allows us to achieve some functionalities that other libraries lack (for example ability to relink database tables). This works very good with all types of Access files except Access 97 .mdb files. We periodically get exceptions when calling OpenDatabase method.

var engine = new DBEngine(); 
var db = engine.OpenDatabase(path);

It periodically throws COMException

Type: System.Runtime.InteropServices.COMException

Message: Cannot open a database created with a previous version of your application.

StackTrace: at Microsoft.Office.Interop.Access.Dao.DBEngineClass.OpenDatabase(String Name, Object Options, Object ReadOnly, Object Connect)

I tried to specify DefaultType, but the result is the same

engine.DefaultType = (int)WorkspaceTypeEnum.dbUseJet;

I would think that Access 97 files are not supported with the version of this library, but sometimes it processes files. Even when it fails, second attempt of opening same set of files pretty much always is being successful. So I wonder if there is a specific reason for these inconsistencies and if someone had experience with solving those.

1 Answers

Version 15.x of the Access Database Engine (ACE) components (e.g., ACEDAO.DLL) corresponds to Access_2013, and Access_2013 completely dropped support for the Access_97 file format. If OpenDatabase sometimes works and at other times throws

Cannot open a database created with a previous version of your application.

then the former is just a fluke. (In trying to disable Access_97 format the developers apparently missed a code path or two.)

TL;DR – Don't count on being able to use Access_97 files with Access_2013+. Convert the Access_97 files to a supported format for your version of Access.

Related