1
votes

I am trying to connect a password protected database in C# using DAO. The code I have previously worked correctly with an unprotected database. Now when trying to connect to the database with adding a default password it is not working.

    var dbe = new DBEngine();
    dbe.DefaultPassword = "abc123";
    Database db = dbe.OpenDatabase(@"C:\Users\x339\Documents\Test.accdb");

I get the error: 'Cannot start your application. The workgroup information file is missing or opened exclusively by another user.' I'm not really sure where I'm going wrong here. Any help would be appreciated.

1

1 Answers

3
votes

Well I wouldn't advise using DAO anymore, but if you must, use this code:

var dbe = new DBEngine();
var databaseFile = @"C:\Users\x339\Documents\Test.accdb";
var password = "abc123";
Database db = dbe.OpenDatabase(databaseFile, False, False, string.Format("MS Access;PWD={0}", password));