Checking for db connectivity

G

Guest

I am trying to check for db connectivity during the onload event. To do this
I use the connection time setting from the connection string. It allows me
to set it higher than the default of 15, however if I set it to 5 for example
it defaults back to 15.

I am up for other ways to accomplish this task. Basically I am trying to
check for db connectivity and then update an xml file.

try
{
m_Connection = new SqlConnection("workstation id=\"BLUEMELJ-A\";packet
size=4096;integrated security=SSPI;data source" +"=\"(local)\";persist
security info=False;Connection Timeout=5;initial catalog=master");

MessageBox.Show(m_Connection.ConnectionTimeout.ToString());

m_Connection.Open();


}
catch (System.Exception ex)
{
MessageBox.Show("Catch");
m_Connection.Close();
}
 
O

Otis Mukinfus

I am trying to check for db connectivity during the onload event. To do this
I use the connection time setting from the connection string. It allows me
to set it higher than the default of 15, however if I set it to 5 for example
it defaults back to 15.

I am up for other ways to accomplish this task. Basically I am trying to
check for db connectivity and then update an xml file.

try
{
m_Connection = new SqlConnection("workstation id=\"BLUEMELJ-A\";packet
size=4096;integrated security=SSPI;data source" +"=\"(local)\";persist
security info=False;Connection Timeout=5;initial catalog=master");

MessageBox.Show(m_Connection.ConnectionTimeout.ToString());

m_Connection.Open();


}
catch (System.Exception ex)
{
MessageBox.Show("Catch");
m_Connection.Close();
}
Why do you think you need to post the same question twice?
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
J

Jeff Dillon

Probably because the timeout isn't set until you actually open it.

Put the messagebox AFTER open to verify

Jeff
 

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

Top