Checking the database has a password???

  • Thread starter Thread starter Jon S via DotNetMonster.com
  • Start date Start date
J

Jon S via DotNetMonster.com

Hi all,

I'm producing a database connection string but I need a way to establish if
the database has a password or not. There are two versions of the database
I'm opening, the first doesn't have a password and the second does. So if
the database has a password then open it with a string that includes a
password, else open it with a string that doesn't include a password. How
can I find out if the database has a password before I try and open it???
I'm using ado.net and C#.

Thanks in advance,
Jon.
 
It will depend on the database you're using, but essentially I think you're
going to have to try xxxConnection.Open in a try catch block and if you get
an exception, check if it's a password problem, then use the next connection
string and repeat
 
Hi Mr Ryan,

I'm using an Access 2000 database. I thought that may have to be the way
around it. I was just wondering if ADO.NET had its own way of testing for a
password before creating the connection string.

Many thanks.
 
Jon - i'm not an Access guy, but I there's not anything in the ADO.NET
library that I've ever heard of that can tell you if the db has a password
on it without attempting to open it. However, there may be a way via access
that I don't know about.
 
¤ Jon - i'm not an Access guy, but I there's not anything in the ADO.NET
¤ library that I've ever heard of that can tell you if the db has a password
¤ on it without attempting to open it. However, there may be a way via access
¤ that I don't know about.

Your suggestion about trapping the error is best, especially in light of the fact that Access
supports two different types of database security.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top