Reputation: 62554
how can I open an MS Access 2007 database with a password in c# ?
I have tried this: Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\BioDB.mdb ;Password=1966;");
but it doesn't work.
Upvotes: 2
Views: 27697
Reputation: 784
This is the connection string to use when you have an Access 2007 - 2013 database protected with a password using the "Set Database Password" function in Access.
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Jet OLEDB:Database Password=MyDbPassword;
Some reports of problems with password longer than 14 characters. Also that some characters might cause trouble. If you are having problems, try change password to a short one with normal characters.
Upvotes: 0
Reputation: 5955
Try this:
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BioDB.mdb;Jet OLEDB:Database Password=1966;"
Upvotes: 2
Reputation: 171549
You'll need to escape that backslash, or precede the string with @
.
Upvotes: 1
Reputation: 21178
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;
From:
http://www.connectionstrings.com/access
And as noted below use @
.
Upvotes: 13