Home All Groups Group Topic Archive Search About

Checking the database has a password???

Author
31 Oct 2005 10:25 AM
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.



Author
31 Oct 2005 1:48 PM
W.G. Ryan - MVP
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
"Jon S via DotNetMonster.com" <u2272@uwe> wrote in message
news:56a7fa1141f8e@uwe...
Show quote
> 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.
>
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-ado-net/200510/1
Author
31 Oct 2005 2:02 PM
Jon S via DotNetMonster.com
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.


Author
31 Oct 2005 6:56 PM
W.G. Ryan - MVP
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 S via DotNetMonster.com" <u2272@uwe> wrote in message
news:56a9dfdcbeda6@uwe...
Show quote
> 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.
>
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-ado-net/200510/1
Author
1 Nov 2005 1:42 PM
Paul Clement
On Mon, 31 Oct 2005 13:56:52 -0500, "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote:

¤ 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)

AddThis Social Bookmark Button