Database: Dont try to open already opened connections for MSSQL
This commit is contained in:
parent
f50b9db499
commit
e93880aed7
@ -66,7 +66,7 @@ Public Class MSSQLServer
|
|||||||
Public Function GetConnection() As SqlConnection
|
Public Function GetConnection() As SqlConnection
|
||||||
Try
|
Try
|
||||||
Dim oConnection = GetSQLConnection()
|
Dim oConnection = GetSQLConnection()
|
||||||
oConnection.Open()
|
OpenSQLConnection(oConnection)
|
||||||
|
|
||||||
Return oConnection
|
Return oConnection
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -151,7 +151,7 @@ Public Class MSSQLServer
|
|||||||
Try
|
Try
|
||||||
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(ConnectionString))
|
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(ConnectionString))
|
||||||
Dim oConnection As New SqlConnection(ConnectionString)
|
Dim oConnection As New SqlConnection(ConnectionString)
|
||||||
oConnection.Open()
|
OpenSQLConnection(oConnection)
|
||||||
oConnection.Close()
|
oConnection.Close()
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -169,10 +169,7 @@ Public Class MSSQLServer
|
|||||||
|
|
||||||
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(Connection.ConnectionString))
|
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(Connection.ConnectionString))
|
||||||
|
|
||||||
If Connection.State = ConnectionState.Closed Then
|
OpenSQLConnection(Connection)
|
||||||
Connection.Open()
|
|
||||||
End If
|
|
||||||
|
|
||||||
Connection.Close()
|
Connection.Close()
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -181,6 +178,18 @@ Public Class MSSQLServer
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function OpenSQLConnection(Connection As SqlConnection) As SqlConnection
|
||||||
|
Try
|
||||||
|
If Connection.State = ConnectionState.Closed Then
|
||||||
|
Connection.Open()
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Connection
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Function GetSQLConnection() As SqlConnection
|
Private Function GetSQLConnection() As SqlConnection
|
||||||
Return GetConnection(CurrentSQLConnectionString)
|
Return GetConnection(CurrentSQLConnectionString)
|
||||||
End Function
|
End Function
|
||||||
@ -188,7 +197,7 @@ Public Class MSSQLServer
|
|||||||
Private Function GetConnection(ConnectionString As String) As SqlConnection
|
Private Function GetConnection(ConnectionString As String) As SqlConnection
|
||||||
Try
|
Try
|
||||||
Dim oConnection As New SqlConnection(ConnectionString)
|
Dim oConnection As New SqlConnection(ConnectionString)
|
||||||
oConnection.Open()
|
OpenSQLConnection(oConnection)
|
||||||
|
|
||||||
Dim oMaskedConnectionString = MaskConnectionString(ConnectionString)
|
Dim oMaskedConnectionString = MaskConnectionString(ConnectionString)
|
||||||
_Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
_Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user