Created
September 28, 2010 14:59
-
-
Save msarchet/601143 to your computer and use it in GitHub Desktop.
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
''' <summary> | |
''' Determines whether database connection valid [the specified connection string]. | |
''' </summary> | |
''' <param name="ConnectionString">The connection string.</param> | |
''' <returns> | |
''' <c>true</c> if [is database connection valid] [the specified connection string]; otherwise, <c>false</c>. | |
''' </returns> | |
Public Function IsDatabaseConnectionValid(ByVal ConnectionString As String) As Boolean | |
Try | |
Using cn As New SqlClient.SqlConnection(ConnectionString) | |
cn.Open() | |
Return True | |
End Using | |
Catch Ex As Exception | |
Return False | |
End Try | |
End Function | |
'Use this to test your connection | |
If Not ScriptAssist.Utilities.Helper.IsDatabaseConnectionValid(Options.ConnectionString_Shared) Then | |
FixDataConnection() | |
End If | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment