Home All Groups Group Topic Archive Search About

Checking for db connectivity

Author
16 Oct 2006 3:45 PM
Bluemel
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();
}

Author
17 Oct 2006 10:43 AM
Otis Mukinfus
On Mon, 16 Oct 2006 08:45:01 -0700, Bluemel <Blue***@discussions.microsoft.com>
wrote:

Show quote
>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
Author
18 Oct 2006 1:10 AM
Jeff Dillon
Probably because the timeout isn't set until you actually open it.

Put the messagebox AFTER open to verify

Jeff

Show quote
"Bluemel" <Blue***@discussions.microsoft.com> wrote in message
news:70EFD07C-0FC7-4F9B-89FC-86B338C54C32@microsoft.com...
>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();
> }

AddThis Social Bookmark Button