ADO.Net Connection Question

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

What is the best way to test to see if a MS SQL DB is running? Does it
throw a specific error when trying to connect to it that I can catch? I am
trying to design my application if the db server is offline to save the db
info locally. Any ideas?

Thanks
 
Hi Mike,

If connection failed during opening, then you should get SqlException
exception. What you need to do is to place only Open method of the
connection into separate Try Catch block and see if it is opened or not
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top