|
|
|
|
@@ -58,6 +58,7 @@ Public Class MSSQLServer
|
|
|
|
|
''' </summary>
|
|
|
|
|
''' <param name="ConnectionString">A connection string with a plain-text password</param>
|
|
|
|
|
''' <returns>The connection string with the password encrypted.</returns>
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Public Shared Function EncryptConnectionString(ConnectionString As String) As String
|
|
|
|
|
Dim oEncryption As New EncryptionLegacy()
|
|
|
|
|
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
|
|
|
|
@@ -72,6 +73,7 @@ Public Class MSSQLServer
|
|
|
|
|
''' </summary>
|
|
|
|
|
''' <param name="ConnectionString">A connection string with a encrypted password</param>
|
|
|
|
|
''' <returns>The connection string with the password decrypted.</returns>
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Public Shared Function DecryptConnectionString(ConnectionString As String) As String
|
|
|
|
|
Dim oEncryption As New EncryptionLegacy()
|
|
|
|
|
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
|
|
|
|
@@ -178,10 +180,12 @@ Public Class MSSQLServer
|
|
|
|
|
Return connectionString
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function TestCanConnect() As Boolean
|
|
|
|
|
Return TestCanConnect(CurrentSQLConnectionString)
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function TestCanConnect(ConnectionString As String) As Boolean
|
|
|
|
|
Try
|
|
|
|
|
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(ConnectionString))
|
|
|
|
|
@@ -195,6 +199,7 @@ Public Class MSSQLServer
|
|
|
|
|
End Try
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function TestCanConnect(Connection As SqlConnection) As Boolean
|
|
|
|
|
Try
|
|
|
|
|
If Connection Is Nothing Then
|
|
|
|
|
@@ -226,10 +231,12 @@ Public Class MSSQLServer
|
|
|
|
|
Return Connection
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function GetSQLConnection() As SqlConnection
|
|
|
|
|
Return GetConnection(CurrentSQLConnectionString)
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function GetConnection(ConnectionString As String) As SqlConnection
|
|
|
|
|
Try
|
|
|
|
|
Dim oConnection As New SqlConnection(ConnectionString)
|
|
|
|
|
@@ -246,6 +253,7 @@ Public Class MSSQLServer
|
|
|
|
|
End Try
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Function MaskConnectionString(ConnectionString As String) As String
|
|
|
|
|
Try
|
|
|
|
|
If ConnectionString Is Nothing OrElse ConnectionString.Length = 0 Then
|
|
|
|
|
@@ -489,6 +497,7 @@ Public Class MSSQLServer
|
|
|
|
|
''' <param name="SqlCommand">the sql statement</param>
|
|
|
|
|
''' <param name="commandtimeout">Optional Timeout</param>
|
|
|
|
|
''' <remarks></remarks>
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Public Sub NewExecuteNonQueryAsync(SqlCommand As String, Optional commandtimeout As Integer = 120)
|
|
|
|
|
_Logger.Debug("NewExecuteNonQueryAsync: Running Query [{0}]", SqlCommand)
|
|
|
|
|
|
|
|
|
|
@@ -509,6 +518,7 @@ Public Class MSSQLServer
|
|
|
|
|
End Try
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
<DebuggerStepThrough()>
|
|
|
|
|
Private Sub NewExecuteNonQueryAsync_Callback(ByVal result As IAsyncResult)
|
|
|
|
|
Dim command As SqlCommand = CType(result.AsyncState, SqlCommand)
|
|
|
|
|
Dim res = command.EndExecuteNonQuery(result)
|
|
|
|
|
|