Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 10, 2012 01:34 AM by Decker Dong - MSFT
Member
118 Points
425 Posts
May 08, 2012 04:42 PM|LINK
Hi,
I using EF, I want check my databse is live or not
private POPContext db = new POPContext();
How can i check it with this code?. If internet down my databse down. I want check connection still live or not
lakmal
Star
8607 Points
1841 Posts
May 08, 2012 05:01 PM|LINK
Do you mean you need ot do a one-off chekc now, or some kind of polling mechanism to keep checking the state of your DB?
May 08, 2012 05:22 PM|LINK
I want one off check
May 08, 2012 05:38 PM|LINK
you just want to write a random query?
var result = (from r in db.someentitly select r).FirstOrDefault;
Participant
947 Points
201 Posts
May 08, 2012 06:17 PM|LINK
Hi
Try:
if (context.Connection.State == System.Data.ConnectionState.Open)
....
May 09, 2012 05:27 PM|LINK
This is throw error, How can i check databse live or not
All-Star
118619 Points
18779 Posts
May 10, 2012 01:34 AM|LINK
gslakmal How can i check databse live or not
It's no need to check whether a database's table exists or not,when you say db with a dot,the intellisense will tell you whether it exists or not。
And you can double click the edmx file to see whether the tables exist or not。
Reguards!
gslakmal
Member
118 Points
425 Posts
Check databse is live
May 08, 2012 04:42 PM|LINK
Hi,
I using EF, I want check my databse is live or not
How can i check it with this code?. If internet down my databse down. I want check connection still live or not
lakmal
christiandev
Star
8607 Points
1841 Posts
Re: Check databse is live
May 08, 2012 05:01 PM|LINK
Do you mean you need ot do a one-off chekc now, or some kind of polling mechanism to keep checking the state of your DB?
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
gslakmal
Member
118 Points
425 Posts
Re: Check databse is live
May 08, 2012 05:22 PM|LINK
I want one off check
christiandev
Star
8607 Points
1841 Posts
Re: Check databse is live
May 08, 2012 05:38 PM|LINK
you just want to write a random query?
var result = (from r in db.someentitly
select r).FirstOrDefault;
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
pierrefrc
Participant
947 Points
201 Posts
Re: Check databse is live
May 08, 2012 06:17 PM|LINK
Hi
Try:
if (context.Connection.State == System.Data.ConnectionState.Open)gslakmal
Member
118 Points
425 Posts
Re: Check databse is live
May 09, 2012 05:27 PM|LINK
var result = (from r in db.someentitly
select r).FirstOrDefault;
This is throw error, How can i check databse live or not
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Check databse is live
May 10, 2012 01:34 AM|LINK
It's no need to check whether a database's table exists or not,when you say db with a dot,the intellisense will tell you whether it exists or not。
And you can double click the edmx file to see whether the tables exist or not。
Reguards!