How to quick-check SQL connection



Hi,

I'm developing an application that runs on laptops that periodically
connect to network. I am collecting data in local tables within the
MDB. I want to recognize the occasional network connection so I can
upload the collected data to SQL server and retrieve updated look-up
information.

This application has 2 linked SQL server tables that are not used until
I find myself connected to the network. Since I have these links, I
figured I could use them with timeout to "guess" my connection status.

So far this works but it takes the default 30 seconds to timeout. I'd
hate to force the user to wait 30 seconds every time they start the
application off-line.

I through together the following code to see if I could alter the
timeout (make it a bit sooner) but it has no effect. Has anybody else
ever done something like this? Is there a better way to detect the
network connection?

' testing with SQL Server shut down
' ---------------------------------------------------------
Dim objRS As New ADODB.Recordset
Dim objCmd As ADODB.Command
Dim conn As ADODB.Connection

' No problem with the following connection block - no timeout
' ---------------------------------------------------------
Set conn = New ADODB.Connection
With conn
.ConnectionString = CurrentProject.BaseConnectionString
.CursorLocation = adUseClient
.CommandTimeout = 10 ' shorten delay to 10 seconds
.Open
End With

' despite the fact that I've set the commandtimeout of the
' connecton to 10 seconds AND I've set the commandtimeout
' of the following ADODB.Command to 10 seconds - the following
' query takes 43 seconds to timeout
' ---------------------------------------------------------
Set objCmd = New ADODB.Command
With objCmd
.CommandType = adCmdText
.CommandText = "SELECT * FROM dbo_MySQLLinkedTable"
.ActiveConnection = conn
.CommandTimeout = 10 ' shorten delay to 10 seconds
Set objCmd = .Execute
End With

.



Relevant Pages

  • Re: SQL connection timeout -- is it pretty useless or what?
    ... What is sounds like your suggesting, it that the OS DDK for network drivers ... timeout interval is still a useless setting in all but the most extreme ... Connection timeout was more useful in the ... wire, it's programmed to wait for quite some time before complaining. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Frequent timeouts, Internet connectivity problem
    ... connection, but it sounds like you've ruled that out.) ... > Sites will timeout and not load anything. ... > * Your network may have been broken or gone down. ... Automatic updates occurred without incidents to SP2. ...
    (microsoft.public.windowsxp.network_web)
  • Re: SQL connection timeout -- is it pretty useless or what?
    ... What is sounds like your suggesting, it that the OS DDK for network ... timeout response from a NIC. ... Connection timeout was more useful in the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SQL connection timeout -- is it pretty useless or what?
    ... The issue is usually that the timeout counter does not start until network ... If the NIC card can't see the wire, ... Is there no way to quickly test a SQL connection in .NET 2.0? ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Problems with Permissions
    ... And SBS server is only take ... the role of an internal server. ... they are all configured to connected to internal network. ... g. Run the Configure Email and Internet Connection Wizard on SBS server. ...
    (microsoft.public.windows.server.sbs)