2

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 Answer 1

4

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));
Sign up to request clarification or add additional context in comments.

6 Comments

+1 for advice on methodology. Use OleDb...see: msdn.microsoft.com/en-us/library/…
Works perfect, thanks. Before I accept as answer why would you suggest against DAO? can you link to some alternates? and documentation if possible.
Well I would start by asking if you really need to be using Access when SQL Express is free.
My ACCDB database can't be changed. How can I offer support to compact without using DAO? I see the linked article but offers no explanation. My driver is JET Access ....
@AndrewTruckle This is a question about DAO. If you have a question about something else, then you should post a new question.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.