Whats the correct way to open a database that has a password?

  • Thread starter Steve1 via DotNetMonster.com
  • Start date
S

Steve1 via DotNetMonster.com

Hi all,

Below is the string I'm using to open a MS Access database using ADO.NET that
is password protected. The variable str_Destination is contains the correct
database path. Can I leave out the other information between the
str_Destination (the database path) and the password or do I need to include
it such as including the uid= bit?? Can someone show me how I need to
construct it??

string str_DestinationPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
" + str_Destination + ";uid=;Pwd=PC60GS7154";

Thanks in advance,
Steve.
 
L

Larry Lard

Steve1 said:
Hi all,

Below is the string I'm using to open a MS Access database using ADO.NET that
is password protected. The variable str_Destination is contains the correct
database path. Can I leave out the other information between the
str_Destination (the database path) and the password or do I need to include
it such as including the uid= bit?? Can someone show me how I need to
construct it??

string str_DestinationPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
" + str_Destination + ";uid=;Pwd=PC60GS7154";

<http://www.connectionstrings.com> any help ?
 
S

Steve1 via DotNetMonster.com

Hi Larry

Thanks for the link but I still haven't solved it. I've changed the string a
little (the latest string is below) but still no joy. I am doing something
wrong? I'm using C#, a MS Access database and trying to open the database
that has a password using ADO.NET. HELP????
 
S

Steve1 via DotNetMonster.com

Hi Larry

Thanks for the link but I still haven't solved it. I've changed the string a
little (the latest string is below) but still no joy. I am doing something
wrong? I'm using C#, a MS Access database and trying to open the database
that has a password using ADO.NET. HELP????

string str_DestinationPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
" + str_Destination + ";User ID=;Password=PC60GS7154;";
 
L

Larry Lard

Steve1 said:
Hi Larry

Thanks for the link but I still haven't solved it. I've changed the string a
little (the latest string is below) but still no joy. I am doing something
wrong? I'm using C#, a MS Access database and trying to open the database
that has a password using ADO.NET. HELP????

string str_DestinationPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
" + str_Destination + ";User ID=;Password=PC60GS7154;";

We need to clarify what you mean by 'database that has a password'. If
you mean that user permissions have been set up in Access (Tools |
Database Security | etc), then you need a connection string of the form
you have currently.

If you mean that when you try and open it in Access, you get a
'Password required' dialog, you need the style of connection string
listed at connectionstrings.com as 'With password', which looks like
this:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet
OLEDB:Database Password=MyDbPassword;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top