473,473 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Determine whether SQL Server exists

_DD
I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?
Sep 17 '06 #1
25 14456
Hello _DD,

Just make connection to DB to check whether it valid or not

_I'd like to include a 'Test Connection' button in an app, for testing
_validity of a SQL connection string. I'd prefer to keep the timeout
_low. What is the conventional way of doing this
_>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 17 '06 #2
If you want a relatively short timeout, you can use ADOX. It is a COM
library that allows you to determine if a server exists, if a database
exists, the objects in a database, etc. The other option I can think of off
hand is to simply connect and allow it to fail.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...
I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?

Sep 17 '06 #3

"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...
| I'd like to include a 'Test Connection' button in an app, for testing
| validity of a SQL connection string. I'd prefer to keep the timeout
| low. What is the conventional way of doing this?

Set the timeout value ("Connect Timeout") in the connection string to the
desired value and issue a SqlConnect.Open. This is the only way to test
whether a Connection string is valid AND the server is accepting the
connection.

Willy.


Sep 17 '06 #4
_DD
On Sun, 17 Sep 2006 16:17:16 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.bewrote:
>
"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com.. .
| I'd like to include a 'Test Connection' button in an app, for testing
| validity of a SQL connection string. I'd prefer to keep the timeout
| low. What is the conventional way of doing this?

Set the timeout value ("Connect Timeout") in the connection string to the
desired value and issue a SqlConnect.Open. This is the only way to test
whether a Connection string is valid AND the server is accepting the
connection.

Willy.
Willy (and others),

I don't think the connection string's "Connect Timeout" affects the
'hard fail' timeout when the connection string points at a server that
does not exist...does it?

I was initially just trying to connect and getting a go/no go. But I
want to do a couple things that seem out of scope for that approach:
I'd like to differentiate between 'server does not exist' and
'database does not exist'. And I'd like to eliminate the long delay
incurred when the server can't be found.

Sep 17 '06 #5
_DD,

Do as in my idea Michael suggest,

Use an SQLClient Connection and put that in a catch, if it fails then there
is no connection. Although in my idea it has not much sense, to do this
appart from your normal ADONET datalayer parts.

SQLConnection con = new SQLConnection();
Try
{con.open;}
Catch
{MessageBox.Show("There is no or malfunction connection");}

If this is not in a form class than you have beside the reference to
SQLClient to set a reference to the System.Windows.Forms for the MessageBox.

Typed in this message so watch typos.

I hope this helps,

Cor
"_DD" <_D*@nospam.comschreef in bericht
news:15********************************@4ax.com...
I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?

Sep 17 '06 #6
_DD.

Your answer here -
http://blah.winsmarts.com//2006-9-De...er_exists.aspx

- Sahil Malik
http://www.winsmarts.com
"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...
I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?

Sep 17 '06 #7
Hello Sahil Malik [MVP C#],

Yep, but this check only existence of SQL Server not its availability.
For example, other DBs like Oracle check you connection by requesting your
credentials, but not checking existence of this db instance

S_DD.
S>
SYour answer here -
Shttp://blah.winsmarts.com//2006-9-De...QL_Server_exis
Sts.aspx
S>
S- Sahil Malik
Shttp://www.winsmarts.com
S"_DD" <_D*@nospam.comwrote in message
Snews:15********************************@4ax.com.. .
S>
>I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 17 '06 #8
Ok, in response to this and the other thread that wanted to test to see if
SQL Server is available try the code from my new blog entry:
http://betav.com/blog/billva/2006/09...numeratin.html
This includes part of an example from my new book that lists all of the SQL
Servers and permits you to determine the state of the service. In other
words you can tell if the SQL Server is running. Does this validate a
ConnectionString? Nope, but it can tell you if the ConnectionString
validation has failed because the service was not there or not running. Even
if you do check to see if you can open a connection, you'll get a pooled
connection that's already connected after the first attempt... not
particularly useful if the service is actually dead... I drone on and on
about this in the book.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...
I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?

Sep 17 '06 #9
Okay you are going to explain a bit more to me.

So once I check for the existence - why can't I just try and connect to it
and verify it's availability?

SM


"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
Hello Sahil Malik [MVP C#],

Yep, but this check only existence of SQL Server not its availability.
For example, other DBs like Oracle check you connection by requesting your
credentials, but not checking existence of this db instance

S_DD.
SSYour answer here -
Shttp://blah.winsmarts.com//2006-9-De...QL_Server_exis
Sts.aspx
SS- Sahil Malik
Shttp://www.winsmarts.com
S"_DD" <_D*@nospam.comwrote in message
Snews:15********************************@4ax.com.. .
S>
>>I'd like to include a 'Test Connection' button in an app, for testing
validity of a SQL connection string. I'd prefer to keep the timeout
low. What is the conventional way of doing this?
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche


Sep 18 '06 #10

"_DD" <_D*@nospam.comwrote in message
news:ch********************************@4ax.com...
| On Sun, 17 Sep 2006 16:17:16 +0200, "Willy Denoyette [MVP]"
| <wi*************@telenet.bewrote:
|
| >
| >"_DD" <_D*@nospam.comwrote in message
| >news:15********************************@4ax.com.. .
| >| I'd like to include a 'Test Connection' button in an app, for testing
| >| validity of a SQL connection string. I'd prefer to keep the timeout
| >| low. What is the conventional way of doing this?
| >
| >Set the timeout value ("Connect Timeout") in the connection string to the
| >desired value and issue a SqlConnect.Open. This is the only way to test
| >whether a Connection string is valid AND the server is accepting the
| >connection.
| >
| >Willy.
|
| Willy (and others),
|
| I don't think the connection string's "Connect Timeout" affects the
| 'hard fail' timeout when the connection string points at a server that
| does not exist...does it?
|
That's right, when connecting to SQL server, SQLClient uses the Sql Native
Interface (SNI) layer (unmanaged code) to connect using the protocol as
specified in the connection string or the default protocol, but SNI ignores
the "Connect Timeout" for the initial physical connect (it issues a
synchronous connect) and uses it's own hard coded timeout. The reason for
this is that SQLClient cannot make any progress without a physical
connection, it needs it to authenticate the client in the first place,
without an authenticated connection you won't be able to progress. That
means that this method cannot be used to achieve your goal.
Now, there might be many reasons for a connect failure: the client network
connection may be broken (both at the physically and network stack level),
same for the server side, the netwok itself may be down (think:router
switches etc...), the server (IP or NP host) may be down or non-existing the
SQL instance may be down or non-existing, SQL instance way be in maintenace
mode etc..,
It's just impossible to distinguish between all these type of failures, all
you can do is check the client side of the network stack, you can check if
the network is up and connected to, you could 'ping' the server (host), you
can 'telnet' the sql server instance (telnet hostaname sqlport), but hey
what if one of these fail, what's the cause?
And what if this succeeds, who says that finally your client will use TCP to
connect to the SQL instance? Or what if authentication fails? or the login
server is not available (when using integrated security in an AD domain
realm).
I think you should forget about this, if a connection fails, you will have
to investigate the failure, but don't try to implement this in an end-user
application, it makes no sense, really.
Willy.



Sep 18 '06 #11

"_DD" <_D*@nospam.comwrote in message
news:ch********************************@4ax.com...
| On Sun, 17 Sep 2006 16:17:16 +0200, "Willy Denoyette [MVP]"
| <wi*************@telenet.bewrote:
|
| >
| >"_DD" <_D*@nospam.comwrote in message
| >news:15********************************@4ax.com.. .
| >| I'd like to include a 'Test Connection' button in an app, for testing
| >| validity of a SQL connection string. I'd prefer to keep the timeout
| >| low. What is the conventional way of doing this?
| >
| >Set the timeout value ("Connect Timeout") in the connection string to the
| >desired value and issue a SqlConnect.Open. This is the only way to test
| >whether a Connection string is valid AND the server is accepting the
| >connection.
| >
| >Willy.
|
| Willy (and others),
|
| I don't think the connection string's "Connect Timeout" affects the
| 'hard fail' timeout when the connection string points at a server that
| does not exist...does it?
|
| I was initially just trying to connect and getting a go/no go. But I
| want to do a couple things that seem out of scope for that approach:
| I'd like to differentiate between 'server does not exist' and
| 'database does not exist'. And I'd like to eliminate the long delay
| incurred when the server can't be found.
|

Ok, did some further investigation, and it looks like SQLClient (V2 of the
framework and SQL2005) effectively considers the "Connect Timeout" value for
the initial connect (+ 1 second). That means that if you set Connect
Timeout=1 in the connectionstring, the connection will timeout after 2
seconds, while a value of 3 will take 4 seconds.

Willy.

Sep 18 '06 #12
Wow--I'm impressed. (seriously).
I agree... but I'm not convinced that the provider "can't" bubble up more
details on why it couldn't connect. I expect that the generic nature of .NET
providers makes it tough to return more granular details about the failure.
Thanks -- Learn something new every day.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:Ow**************@TK2MSFTNGP03.phx.gbl...
>
"_DD" <_D*@nospam.comwrote in message
news:ch********************************@4ax.com...
| On Sun, 17 Sep 2006 16:17:16 +0200, "Willy Denoyette [MVP]"
| <wi*************@telenet.bewrote:
|
| >
| >"_DD" <_D*@nospam.comwrote in message
| >news:15********************************@4ax.com.. .
| >| I'd like to include a 'Test Connection' button in an app, for testing
| >| validity of a SQL connection string. I'd prefer to keep the timeout
| >| low. What is the conventional way of doing this?
| >
| >Set the timeout value ("Connect Timeout") in the connection string to
the
| >desired value and issue a SqlConnect.Open. This is the only way to test
| >whether a Connection string is valid AND the server is accepting the
| >connection.
| >
| >Willy.
|
| Willy (and others),
|
| I don't think the connection string's "Connect Timeout" affects the
| 'hard fail' timeout when the connection string points at a server that
| does not exist...does it?
|
That's right, when connecting to SQL server, SQLClient uses the Sql Native
Interface (SNI) layer (unmanaged code) to connect using the protocol as
specified in the connection string or the default protocol, but SNI
ignores
the "Connect Timeout" for the initial physical connect (it issues a
synchronous connect) and uses it's own hard coded timeout. The reason for
this is that SQLClient cannot make any progress without a physical
connection, it needs it to authenticate the client in the first place,
without an authenticated connection you won't be able to progress. That
means that this method cannot be used to achieve your goal.
Now, there might be many reasons for a connect failure: the client network
connection may be broken (both at the physically and network stack level),
same for the server side, the netwok itself may be down (think:router
switches etc...), the server (IP or NP host) may be down or non-existing
the
SQL instance may be down or non-existing, SQL instance way be in
maintenace
mode etc..,
It's just impossible to distinguish between all these type of failures,
all
you can do is check the client side of the network stack, you can check if
the network is up and connected to, you could 'ping' the server (host),
you
can 'telnet' the sql server instance (telnet hostaname sqlport), but hey
what if one of these fail, what's the cause?
And what if this succeeds, who says that finally your client will use TCP
to
connect to the SQL instance? Or what if authentication fails? or the login
server is not available (when using integrated security in an AD domain
realm).
I think you should forget about this, if a connection fails, you will have
to investigate the failure, but don't try to implement this in an end-user
application, it makes no sense, really.
Willy.



Sep 18 '06 #13

"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
| Wow--I'm impressed. (seriously).
| I agree... but I'm not convinced that the provider "can't" bubble up more
| details on why it couldn't connect. I expect that the generic nature of
..NET
| providers makes it tough to return more granular details about the
failure.
| Thanks -- Learn something new every day.
|
| --
|

William, the provider could possibly bubble up some more details, but it can
only bubble up what's coming from the network stack.
To explain what I mean we should take a close look at (ISO) stack as used by
SQL server (or any other DBMS):
Starting from the top - the Application layer - we have the SQLClient
managed API, (SNI and the TDS parser),
below this one (the Session layer) we have the network protocol library
(pipes, sockets, shared memory etc...),
sitting in top of our Network stack (except for the shared memory protocol),
this one depends on the used client session protocol library, but for the
socket protocol we have TCP at the transport layer, IP at the protocol
layer, HDLC the network layer and finally the physical layer (Ethernet LAN,
WAN, etc....)
Now , you see that if you want to bubble up detailed failure notifications,
you need a Network stack in which each layer not only provides in error
recovery but also returns detailed error message when something goes wrong
at the lower layer to the upper layer, and here's where the problem starts.
The network stack does not (should not and in most cases cannot) provide
this status reporting (though ICMP provides some possibilities, it's
un-common to use it from a regular application), it only has provisions for
error recovery at his own layer, and a very simple protocol for error
reporting to it's upper layer. Consider that the physical layer cannot
connect (say cable broken), it will signal it's upper layer that a physical
connection is not possible so the network layer cannot push a connection
HDLC request frame through the network infrastructure. But, it cannot say
what's actually broken at the physical layer, where is the cable broken? at
the client side or at the switch or the router or ...?
The same is true for every layer in the stack, in some cases detailed info
may be available, like irrecoverable transmission errors at the HDLC layer,
but most of the time there is no such info, and more, it makes no sense to
"bubble up" this to the application layer, it's not it's concern, it's up to
the IP layer to start a recovery action (retry) when there is a failure at
the Network layer and it's up to IP to signal the same to it's upper layer
and so on until you reach the application layer, where the only thing that
can be done is report a failure message to the user and/or start a recovery
action, that is, retry the SQLClient Open or give up and let the network and
the DB admin's try to find out the cause of the failure.

Willy.
Willy.

Sep 18 '06 #14
Yes, this has been detailed to me about a dozen times over the last
decade... ;) You have a firm grasp on the issues.I see it as a long-term
problem that MS and the provider developers have not been able to fully
address. I've worked with these drivers for awhile and I know it's tough to
be able to bubble up something that's only manifested as a timeout on a NIC
or a "broken pipe" back from the server. When we were (a bit) closer to the
TDS with DBLib we could give developers a bit more information--far more
than the "stuff happened" errors we now see. I also think the exception
string that comes back suggesting that the server is not properly configured
is like telling a driver that he should have been driving slower after
having a bread truck sideswipe him on the freeway.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:u5**************@TK2MSFTNGP05.phx.gbl...
>
"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
| Wow--I'm impressed. (seriously).
| I agree... but I'm not convinced that the provider "can't" bubble up
more
| details on why it couldn't connect. I expect that the generic nature of
.NET
| providers makes it tough to return more granular details about the
failure.
| Thanks -- Learn something new every day.
|
| --
|

William, the provider could possibly bubble up some more details, but it
can
only bubble up what's coming from the network stack.
To explain what I mean we should take a close look at (ISO) stack as used
by
SQL server (or any other DBMS):
Starting from the top - the Application layer - we have the SQLClient
managed API, (SNI and the TDS parser),
below this one (the Session layer) we have the network protocol library
(pipes, sockets, shared memory etc...),
sitting in top of our Network stack (except for the shared memory
protocol),
this one depends on the used client session protocol library, but for the
socket protocol we have TCP at the transport layer, IP at the protocol
layer, HDLC the network layer and finally the physical layer (Ethernet
LAN,
WAN, etc....)
Now , you see that if you want to bubble up detailed failure
notifications,
you need a Network stack in which each layer not only provides in error
recovery but also returns detailed error message when something goes wrong
at the lower layer to the upper layer, and here's where the problem
starts.
The network stack does not (should not and in most cases cannot) provide
this status reporting (though ICMP provides some possibilities, it's
un-common to use it from a regular application), it only has provisions
for
error recovery at his own layer, and a very simple protocol for error
reporting to it's upper layer. Consider that the physical layer cannot
connect (say cable broken), it will signal it's upper layer that a
physical
connection is not possible so the network layer cannot push a connection
HDLC request frame through the network infrastructure. But, it cannot say
what's actually broken at the physical layer, where is the cable broken?
at
the client side or at the switch or the router or ...?
The same is true for every layer in the stack, in some cases detailed info
may be available, like irrecoverable transmission errors at the HDLC
layer,
but most of the time there is no such info, and more, it makes no sense to
"bubble up" this to the application layer, it's not it's concern, it's up
to
the IP layer to start a recovery action (retry) when there is a failure at
the Network layer and it's up to IP to signal the same to it's upper layer
and so on until you reach the application layer, where the only thing that
can be done is report a failure message to the user and/or start a
recovery
action, that is, retry the SQLClient Open or give up and let the network
and
the DB admin's try to find out the cause of the failure.

Willy.
Willy.



Sep 18 '06 #15

"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
| Yes, this has been detailed to me about a dozen times over the last
| decade... ;) You have a firm grasp on the issues.I see it as a long-term
| problem that MS and the provider developers have not been able to fully
| address.

True, but even if the Network stack could bubble up extended error
information (through error codes f.i), they would not be able to report
details about what's wrong at the physical network layer (infrastructure).
Even in the simple case like a wrong hostname (program error) or instance
name , the network layer has no idea about what's wrong in this case. The
"name lookup" isn't able to resolve the address, but why? Say that the error
message in this case looks like "Name lookup for server "xxxx" failed , make
sure the server name refers to an existing server, check you DNS server or
your etc\hosts file. Check also you network infrastructure, like routers and
switches and cables."., honestly, this is not what I call more helpfull as
we get now :-)

Another thing you must consider is performance, the network stack (the
winsock library and NDIS) is not a place to waste too many cycles, I really
don't think that 3COM and MS are willing to change the NSDIS specifications,
nor will anyone ever change the WinSock2 specifications,let alone change the
implementation, in order to include extended error reporting.
I have since long accepted this inconvenience, just like I accepted that
TCP/IP is far from perfect, I'm sure you also have done so ;-).

Willy.


Sep 18 '06 #16
Willy and Bill,

You have forgotten the power cables on more places.

To be serious, what has this for sense. In my opinion is it only needed to
see if the data on the DataBase server is reachable. For that Michael's
solution as first stated is in my opinion more than enough,

Cor

"Willy Denoyette [MVP]" <wi*************@telenet.beschreef in bericht
news:e3**************@TK2MSFTNGP03.phx.gbl...
>
"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
| Yes, this has been detailed to me about a dozen times over the last
| decade... ;) You have a firm grasp on the issues.I see it as a long-term
| problem that MS and the provider developers have not been able to fully
| address.

True, but even if the Network stack could bubble up extended error
information (through error codes f.i), they would not be able to report
details about what's wrong at the physical network layer (infrastructure).
Even in the simple case like a wrong hostname (program error) or instance
name , the network layer has no idea about what's wrong in this case. The
"name lookup" isn't able to resolve the address, but why? Say that the
error
message in this case looks like "Name lookup for server "xxxx" failed ,
make
sure the server name refers to an existing server, check you DNS server or
your etc\hosts file. Check also you network infrastructure, like routers
and
switches and cables."., honestly, this is not what I call more helpfull as
we get now :-)

Another thing you must consider is performance, the network stack (the
winsock library and NDIS) is not a place to waste too many cycles, I
really
don't think that 3COM and MS are willing to change the NSDIS
specifications,
nor will anyone ever change the WinSock2 specifications,let alone change
the
implementation, in order to include extended error reporting.
I have since long accepted this inconvenience, just like I accepted that
TCP/IP is far from perfect, I'm sure you also have done so ;-).

Willy.


Sep 19 '06 #17

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
| Willy and Bill,
|
| You have forgotten the power cables on more places.
|
| To be serious, what has this for sense. In my opinion is it only needed to
| see if the data on the DataBase server is reachable. For that Michael's
| solution as first stated is in my opinion more than enough,
|
| Cor
|

Which was exactly my answer, all I did was answering both of OP's questions:

Q1 ... testing validity of a SQL connection string ...
A. use SqlConnect.Open
Q2 ... to keep the timeout low...
A. set the connetionstring "Connect Timeout" parameter to a lower value.

The rest was just a technical chat with Bill.

Note that I don't necessarily agree with the OP to add a "test connection"
in an end-user's application (end-users should not test connections).

Willy.

Sep 19 '06 #18
Using the "test connection" approach is like picking up the phone to see if
there is dialtone. The second you hang up the proverbial beer truck can hit
the phone pole outside and cut you off. I suggest robust exception handlers
to deal with the stuff that happens when connecting. This is why the
"Getting Connected" chapter in my new book is 70 or so pages long (IIRC).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:up**************@TK2MSFTNGP06.phx.gbl...
>
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
| Willy and Bill,
|
| You have forgotten the power cables on more places.
|
| To be serious, what has this for sense. In my opinion is it only needed
to
| see if the data on the DataBase server is reachable. For that Michael's
| solution as first stated is in my opinion more than enough,
|
| Cor
|

Which was exactly my answer, all I did was answering both of OP's
questions:

Q1 ... testing validity of a SQL connection string ...
A. use SqlConnect.Open
Q2 ... to keep the timeout low...
A. set the connetionstring "Connect Timeout" parameter to a lower value.

The rest was just a technical chat with Bill.

Note that I don't necessarily agree with the OP to add a "test connection"
in an end-user's application (end-users should not test connections).

Willy.

Sep 19 '06 #19
Bill,

What is the trouble to help that the beer is not going over the road and
help to unload that beer truck?

Although Willy will probably write that if it is about beer, you have to be
sure it is good beer first before you are doing work that has no sense.

(He is from Belgian you know, and there is no country in the world with more
beer experts).

:-)

Cor
"William (Bill) Vaughn" <bi**************@nwlink.comschreef in bericht
news:ur**************@TK2MSFTNGP04.phx.gbl...
Using the "test connection" approach is like picking up the phone to see
if there is dialtone. The second you hang up the proverbial beer truck can
hit the phone pole outside and cut you off. I suggest robust exception
handlers to deal with the stuff that happens when connecting. This is why
the "Getting Connected" chapter in my new book is 70 or so pages long
(IIRC).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:up**************@TK2MSFTNGP06.phx.gbl...
>>
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
| Willy and Bill,
|
| You have forgotten the power cables on more places.
|
| To be serious, what has this for sense. In my opinion is it only needed
to
| see if the data on the DataBase server is reachable. For that Michael's
| solution as first stated is in my opinion more than enough,
|
| Cor
|

Which was exactly my answer, all I did was answering both of OP's
questions:

Q1 ... testing validity of a SQL connection string ...
A. use SqlConnect.Open
Q2 ... to keep the timeout low...
A. set the connetionstring "Connect Timeout" parameter to a lower value.

The rest was just a technical chat with Bill.

Note that I don't necessarily agree with the OP to add a "test
connection"
in an end-user's application (end-users should not test connections).

Willy.


Sep 19 '06 #20

"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
| Using the "test connection" approach is like picking up the phone to see
if
| there is dialtone. The second you hang up the proverbial beer truck can
hit
| the phone pole outside and cut you off. I suggest robust exception
handlers
| to deal with the stuff that happens when connecting. This is why the
| "Getting Connected" chapter in my new book is 70 or so pages long (IIRC).
|
| --
| ____________________________________

Oh no please, not a beer truck :-(
Any idea when the book will hit the streets?

Willy.
Sep 19 '06 #21
Nov 6th at the Connections conference in Las Vegas. I'm leasing the Goodyear
blimp... ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>
"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
| Using the "test connection" approach is like picking up the phone to see
if
| there is dialtone. The second you hang up the proverbial beer truck can
hit
| the phone pole outside and cut you off. I suggest robust exception
handlers
| to deal with the stuff that happens when connecting. This is why the
| "Getting Connected" chapter in my new book is 70 or so pages long
(IIRC).
|
| --
| ____________________________________

Oh no please, not a beer truck :-(
Any idea when the book will hit the streets?

Willy.


Sep 20 '06 #22
Bill,

A pity that the transport cost from that book with so much pages with
information is probably to expensive for us in the Benelux to buy.

Cor

"William (Bill) Vaughn" <bi**************@nwlink.comschreef in bericht
news:OA**************@TK2MSFTNGP06.phx.gbl...
Nov 6th at the Connections conference in Las Vegas. I'm leasing the
Goodyear blimp... ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>
"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
| Using the "test connection" approach is like picking up the phone to
see
if
| there is dialtone. The second you hang up the proverbial beer truck can
hit
| the phone pole outside and cut you off. I suggest robust exception
handlers
| to deal with the stuff that happens when connecting. This is why the
| "Getting Connected" chapter in my new book is 70 or so pages long
(IIRC).
|
| --
| ____________________________________

Oh no please, not a beer truck :-(
Any idea when the book will hit the streets?

Willy.



Sep 21 '06 #23
Benelux? "too expensive ??" you are talking like the average Dutchman (or
should I say: like an "Hollander" a native inhabitant of Holland), however,
keep in mind that not all Benelux inhabitants are Dutchman :-)

Willy.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
| Bill,
|
| A pity that the transport cost from that book with so much pages with
| information is probably to expensive for us in the Benelux to buy.
|
| Cor
|
| "William (Bill) Vaughn" <bi**************@nwlink.comschreef in bericht
| news:OA**************@TK2MSFTNGP06.phx.gbl...
| Nov 6th at the Connections conference in Las Vegas. I'm leasing the
| Goodyear blimp... ;)
| >
| --
| ____________________________________
| William (Bill) Vaughn
| Author, Mentor, Consultant
| Microsoft MVP
| INETA Speaker
| www.betav.com/blog/billva
| www.betav.com
| Please reply only to the newsgroup so that others can benefit.
| This posting is provided "AS IS" with no warranties, and confers no
| rights.
| __________________________________
| >
| "Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
| news:%2****************@TK2MSFTNGP04.phx.gbl...
| >>
| >"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
| >news:ur**************@TK2MSFTNGP04.phx.gbl...
| >| Using the "test connection" approach is like picking up the phone to
| >see
| >if
| >| there is dialtone. The second you hang up the proverbial beer truck
can
| >hit
| >| the phone pole outside and cut you off. I suggest robust exception
| >handlers
| >| to deal with the stuff that happens when connecting. This is why the
| >| "Getting Connected" chapter in my new book is 70 or so pages long
| >(IIRC).
| >|
| >| --
| >| ____________________________________
| >>
| >Oh no please, not a beer truck :-(
| >Any idea when the book will hit the streets?
| >>
| >Willy.
| >>
| >>
| >
| >
|
|
Sep 21 '06 #24
Cor, I will send one to you if you'll send me your address (privately).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
Bill,

A pity that the transport cost from that book with so much pages with
information is probably to expensive for us in the Benelux to buy.

Cor

"William (Bill) Vaughn" <bi**************@nwlink.comschreef in bericht
news:OA**************@TK2MSFTNGP06.phx.gbl...
>Nov 6th at the Connections conference in Las Vegas. I'm leasing the
Goodyear blimp... ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>>
"William (Bill) Vaughn" <bi**************@nwlink.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
| Using the "test connection" approach is like picking up the phone to
see
if
| there is dialtone. The second you hang up the proverbial beer truck
can
hit
| the phone pole outside and cut you off. I suggest robust exception
handlers
| to deal with the stuff that happens when connecting. This is why the
| "Getting Connected" chapter in my new book is 70 or so pages long
(IIRC).
|
| --
| ____________________________________

Oh no please, not a beer truck :-(
Any idea when the book will hit the streets?

Willy.




Sep 21 '06 #25
_DD
On Tue, 19 Sep 2006 10:26:32 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.bewrote:
>
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
. In my opinion is it only needed to
| see if the data on the DataBase server is reachable. For that Michael's
| solution as first stated is in my opinion more than enough,
>Which was exactly my answer, all I did was answering both of OP's questions:

Q1 ... testing validity of a SQL connection string ...
A. use SqlConnect.Open
Q2 ... to keep the timeout low...
A. set the connetionstring "Connect Timeout" parameter to a lower value.

The rest was just a technical chat with Bill.

Note that I don't necessarily agree with the OP to add a "test connection"
in an end-user's application (end-users should not test connections).
Sorry about the late reply. Posting problems.

I'm not sure that the "Test Connection" will be available to final end
users, but there are enough potential problems that having the "Test
Button" is important during early phases.

There are two things that I was trying to address:

The timout is unnecessarily long. The program stalls out while the
connect times out.

There is insufficient info returned to analyze the problem.

While the release version may end up just going dead for a while (as
it appears to the user), I would like to avoid that, and provide more
coherent information on how to correct the failure.

I liked the "slow down" error message when getting hit by the bread
truck, Bill. <g That was actually a good analogy.
Sep 27 '06 #26

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: OvErboRed | last post by:
Hi, I'm trying to determine whether a given URL exists. I'm new to Python but I think that urllib is the tool for the job. However, if I give it a non-existent file, it simply returns the 404 page....
16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
3
by: Gareth Tonnessen | last post by:
I need to have a clean way to determine whether a query exists without trying to open it and getting an error message. Is there a simple way to determine whether an object exists in a database?...
14
by: Kayle | last post by:
How should we check if the '\0' characters exists in the string as I am confused that some books mentioned that we have to check whether we need to make sure that we pass the...
1
by: Ashabul Yeameen | last post by:
I am writing a program which at some point need to call fputwc() function. But since I want to make this code portable I've decided to write my own fputwc() funcion where the compiler doesn't...
0
by: Roz Lee | last post by:
I need to determine whether the client browser has disabled the Active Scripting option in their browser security settings as they will be unable to log in to my asp.net site if they have, in which...
1
by: topramen | last post by:
does any one here know of a good way to to determine whether or not a given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir \myfile.txt")? i started attacking this problem by...
9
by: Mark Berry | last post by:
Hi, How can I determine whether an object is derived from another object? My specific example is that I have a CustomError class with several specific error types that derive from it...
3
by: abhimanyu | last post by:
I have a method Marshal.IsComObject(...) that returns TRUE if an object is a COM object. I have an object of Excel.Worksheet that I released using Marshal.ReleaseComObject(...). I want to iterate...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.