Hi,
I am new to c# and just trying out c# with ms access. First problem i
encountered is how do i open up ms access that has password.
Here is my current codes which working fine if there is no password on ms
access:
//Specify sql server-specific connection string
private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb";
//Main connector
public OleDbConnection thisconnection;
public clsDBBasic()
{
//Open the database
try
{
thisconnection = new OleDbConnection(strdns);
thisconnection.Open();
}
catch
{
throw new Exception("Open data error.");
}
}
Can anyone please tell me how to open ms access with password protected? I
have tried change the STRDNS variabale to
private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;ID=sa;PWD=abc123;Persist Security Info=true"; //Not
working
private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working
Mark Rae - 24 Nov 2006 00:37 GMT
> Can anyone please tell me how to open ms access with password protected? I
> have tried change the STRDNS variabale to
[quoted text clipped - 5 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working
private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;Jet OLEDB:Database Password=abc123;"
beaker - 25 Nov 2006 09:33 GMT
>>Can anyone please tell me how to open ms access with password protected? I
>>have tried change the STRDNS variabale to
[quoted text clipped - 8 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;Jet OLEDB:Database Password=abc123;"
I was about to ask the very same question!
Is the only way to tell if the DB is password protected to catch the
exception thrown by Open() and check the message for 'Not a valid
password'? Just seems a bit untidy to me.
Thanks,
Gary
RobinS - 24 Nov 2006 07:24 GMT
Here's my connection string for connecting to an Access
database that has a database password. Sorry, this is VB,
but I think you can just change the & to + to do C#.
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\MyDatabase.mdb;" & _
"Persist Security Info=False;Jet OLEDB:Database Password=mypassword"
Robin S.
---------------------------------------
> Hi,
>
[quoted text clipped - 34 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working