I would create a new connection string with a very short connection timeout
Dim Conn As New SqlClient.SqlConnection("server=127.0.0.1;uid=username;pwd=password;database=mydatabasename;Connect Timeout=5")
Try
Conn.Open()
Catch exSQL As SqlClient.SqlException
If exSQL.Message.ToUpper().Contains("LOGIN FAILED") Then
MsgBox("Invalid User/Password")
Else
MsgBox("SQL Error: " & exSQL.Message)
End If
Exit Sub
Catch ex As Exception
MsgBox("Something went wrong.")
Exit Sub
Finally
Conn.Close()
Conn.Dispose()
End Try
source
share