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