Last active
August 24, 2017 14:12
-
-
Save fredgdaley2/33eef1a8f2caaa394f4154a24f7c3f78 to your computer and use it in GitHub Desktop.
Check if an MSSQL server is alive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Data.SqlClient | |
Public Function IsMsSqlServerAvailable(ByVal dbCnxStr As String) As Boolean | |
Try | |
Using srvrConnection = New SqlConnection(dbCnxStr) | |
Try | |
srvrConnection.Open() | |
Return True | |
Catch ex As SqlException | |
Return False | |
End Try | |
End Using | |
Catch ex as ArgumentException | |
Return False; | |
End Try | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment