I am doing that now. I think the code snippet, which I have mentioned was failing to detect strictly whether the DB is up or not because the connection object is pooled. I want to know if there is any better way of achieving the same ?
If you look at my code, I am doing the same, but what's happening is even if I disconnect the cable, the _con.Open executes without any error and the connection State also shows OPEN. I added one additional step where I am querying something from table,
this steps ensures if the DB is up or not. Don't think this soln is elegant but till I get a better soln, I will go with that approach.
None
0 Points
5 Posts
Need to check whether DB is up or not.
Jan 24, 2012 02:38 AM|pure_m23|LINK
Member
633 Points
224 Posts
Re: Need to check whether DB is up or not.
Jan 24, 2012 02:55 AM|Rab Nawaz Khan|LINK
please visit the below URL, it may solve your problem
http://stackoverflow.com/questions/927567/in-c-sharp-what-is-the-best-way-to-determine-if-a-database-is-up-and-running
All-Star
120084 Points
27963 Posts
Moderator
MVP
Re: Need to check whether DB is up or not.
Jan 24, 2012 02:55 AM|ignatandrei|LINK
read at least a table.
None
0 Points
5 Posts
Re: Need to check whether DB is up or not.
Jan 25, 2012 02:31 AM|pure_m23|LINK
I am doing that now. I think the code snippet, which I have mentioned was failing to detect strictly whether the DB is up or not because the connection object is pooled. I want to know if there is any better way of achieving the same ?
Regards,
M
None
0 Points
5 Posts
Re: Need to check whether DB is up or not.
Jan 25, 2012 02:46 AM|pure_m23|LINK
HI Khan,
If you look at my code, I am doing the same, but what's happening is even if I disconnect the cable, the _con.Open executes without any error and the connection State also shows OPEN. I added one additional step where I am querying something from table, this steps ensures if the DB is up or not. Don't think this soln is elegant but till I get a better soln, I will go with that approach.
Regards,
M