2

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.

4
  • 2
    What exact error message are you receiving? There are many possible reasons why you couldn't open that database. Commented Mar 9, 2010 at 19:51
  • As a side note, one of my personal favorites is the complete lack of a provider for x64. I really don't like access. Commented Mar 9, 2010 at 20:05
  • 1
    You can use Access 2010 beta for x64, drivers available now for download. Commented Mar 10, 2010 at 14:04
  • Why would there be a 64-bit Jet/ACE when there's no released 64-bit Access? If 64-bit is required, why have you chosen a data store that doesn't have 64-bit support? Looks like pilot error to me, not some lack in the database engine or its support by MS. Commented Mar 12, 2010 at 4:31

4 Answers 4

13
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 @.

Sign up to request clarification or add additional context in comments.

1 Comment

how about username?
2

Try this:

@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BioDB.mdb;Jet OLEDB:Database Password=1966;"

1 Comment

how about username?
1

You'll need to escape that backslash, or precede the string with @.

5 Comments

Er, what backslash needs to be escaped? And in what context?
The only backslash in the original post; in the context of a C# string.
OK. C# programmers would understand that, but I think it would be better to be more explicit in an answer in specifying exactly what you're addressing.
The OP stated they are using C# and the question is tagged C#. I think it is a bit redundant to keep stating the language.
I think you're assuming too much about your readers and about the context in which your answer may be read.
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.