diff --git a/Modules.Database/MSSQLServer.vb b/Modules.Database/MSSQLServer.vb
index 05f67d8b..93bf5a68 100644
--- a/Modules.Database/MSSQLServer.vb
+++ b/Modules.Database/MSSQLServer.vb
@@ -168,7 +168,11 @@ Public Class MSSQLServer
End If
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(Connection.ConnectionString))
- Connection.Open()
+
+ If Connection.State = ConnectionState.Closed Then
+ Connection.Open()
+ End If
+
Connection.Close()
Return True
Catch ex As Exception
@@ -199,6 +203,10 @@ Public Class MSSQLServer
Private Function MaskConnectionString(ConnectionString As String) As String
Try
+ If ConnectionString Is Nothing OrElse ConnectionString.Length = 0 Then
+ Throw New ArgumentNullException("ConnectionString")
+ End If
+
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
Return oConnectionString
@@ -229,7 +237,6 @@ Public Class MSSQLServer
End Using
End Function
-
Public Async Function GetDatatableAsync(SqlCommand As String) As Task(Of DataTable)
Return Await Task.Run(Function() GetDatatable(SqlCommand, _Timeout))
End Function
@@ -244,10 +251,6 @@ Public Class MSSQLServer
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
Optional Transaction As SqlTransaction = Nothing,
Optional Timeout As Integer = 120) As DataTable
- If TestCanConnect(SqlConnection) = False Then
- Return Nothing
- End If
-
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
Dim oTable As New DataTable() With {.TableName = TABLE_DEFAULT}
@@ -262,8 +265,6 @@ Public Class MSSQLServer
_Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", SqlCommand)
oAdapter.Fill(oTable)
-
- _Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", SqlCommand)
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
@@ -308,10 +309,6 @@ Public Class MSSQLServer
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
Optional Transaction As SqlTransaction = Nothing,
Optional Timeout As Integer = 120) As Boolean
- If TestCanConnect(SqlConnection) = False Then
- Return False
- End If
-
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
Try
@@ -365,9 +362,6 @@ Public Class MSSQLServer
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
Optional Transaction As SqlTransaction = Nothing,
Optional Timeout As Integer = 120) As Object
- If TestCanConnect() = False Then
- Return Nothing
- End If
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
Dim oResult As Object = Nothing
@@ -433,10 +427,6 @@ Public Class MSSQLServer
''' Optional Timeout
'''
Public Sub NewExecuteNonQueryAsync(SqlCommand As String, Optional commandtimeout As Integer = 120)
- If TestCanConnect() = False Then
- Exit Sub
- End If
-
_Logger.Debug("NewExecuteNonQueryAsync: Running Query [{0}]", SqlCommand)
Try