Link to home
Start Free TrialLog in
Avatar of rmmarsh
rmmarshFlag for United States of America

asked on

How to tell if database is detached?

I have a C# program that under Windows XP is unable to connect to a SQL Server Express database.  The logs indicate there is a problem with the logon id, but the users chose Windows Authentication method, so there shouldn't be an issue with user id or password, right?  I am wondering if the database is detached from the server... if so, is there a way I can tell?  how about telling programmatically?

Thanks for your help...
Avatar of osiris247
osiris247
Flag of United States of America image

Not sure you can test if a database is detached specifically from C#, you can certainly handle SQLexceptions thrown from the calling command.

When you say use windows logon, you must have their windows logon added to the users in SQL.  If they are on the localhost then normally this is set during installation and will be fine...if they are from another machine it will use their windows logon.

I suggest to use a SQL login, and test that.

Can you connect to SQL with SQL management studio and query the database?

hopt this helps
o
Avatar of rmmarsh

ASKER

The connection using SQL Management is next... have sent an email to user asking them to download it and give it a try... I will post the results here as soon as I get them...

THanks for your help...
ASKER CERTIFIED SOLUTION
Avatar of osiris247
osiris247
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

ASKER

good point... I'll post the results as soon as I get them...

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ositear
ositear

on what andy said about permissions, try creating a view over that view for your user, so you don't have to grant access to your DB structure.

Anyway, those kind of situations SHOULD be handled by a try {} catch {} statement.
Avatar of rmmarsh

ASKER

The problem was trying to use the connection before it was instantiated... dumb mistake...

Thanks again for the help...