Funkcja posiada 2 parametry:
sConn - jest to connectionstring
Timeout - określa maksymalny czas sprawdzania
Function ServerTest(sConn As String, Optional Timeout As Long = 5) As Boolean
On Error GoTo ERR_Handler:
Dim aConn As ADODB.Connection
Set aConn = New ADODB.Connection
aConn.ConnectionTimeout = Timeout
aConn.ConnectionString = sConn
aConn.Open
ServerTest = CBool(aConn.State)
aConn.Close
END_Handler:
Set aConn = Nothing
Exit Function
ERR_Handler:
ServerTest = False
Resume END_Handler:
End Function
Brak komentarzy:
Prześlij komentarz