how to open access database with password in C#?
24,676
Solution 1
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 @
.
Solution 2
Try this:
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BioDB.mdb;Jet OLEDB:Database Password=1966;"
Solution 3
You'll need to escape that backslash, or precede the string with @
.
Author by
Gold
Updated on April 19, 2020Comments
-
Gold about 4 years
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.
-
David-W-Fenton about 14 yearsEr, what backslash needs to be escaped? And in what context?
-
D'Arcy Rittich about 14 yearsThe only backslash in the original post; in the context of a C# string.
-
David-W-Fenton about 14 yearsOK. 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.
-
D'Arcy Rittich about 14 yearsThe OP stated they are using C# and the question is tagged C#. I think it is a bit redundant to keep stating the language.
-
David-W-Fenton about 14 yearsI think you're assuming too much about your readers and about the context in which your answer may be read.
-
Admin almost 7 yearshow about username?
-
Admin almost 7 yearshow about username?