diff --git a/Modules.Database/Adapters/MSSQLServer.vb b/Modules.Database/Adapters/MSSQLServer.vb index b831bb2b..dada945b 100644 --- a/Modules.Database/Adapters/MSSQLServer.vb +++ b/Modules.Database/Adapters/MSSQLServer.vb @@ -141,12 +141,17 @@ Public Class MSSQLServer End Select End Function + Public Function GetConnectionStringForId(pConnectionId As Integer) As String + Return Get_ConnectionStringforID(pConnectionId) + End Function + Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String - Dim connectionString As String = "" + Dim oConnectionString As String = "" + Try - Dim oDTConnection As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}") - If oDTConnection.Rows.Count = 1 Then - Dim oRow As DataRow = oDTConnection.Rows(0) + Dim oTable As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}") + If oTable.Rows.Count = 1 Then + Dim oRow As DataRow = oTable.Rows(0) Dim oProvider = oRow.Item("SQL_PROVIDER").ToString.ToUpper Dim oServer = oRow.Item("SERVER") Dim oDatabase = oRow.Item("DATENBANK") @@ -156,28 +161,33 @@ Public Class MSSQLServer Select Case oProvider Case "MS-SQL" If oUser = "WINAUTH" Then - connectionString = $"Server={oServer};Database={oDatabase};Trusted_Connection=True;" + oConnectionString = $"Server={oServer};Database={oDatabase};Trusted_Connection=True;" Else - connectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};" + oConnectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};" End If - Case "Oracle" + + Case "ORACLE" If oRow.Item("BEMERKUNG").ToString.Contains("without tnsnames") Then - connectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};" + oConnectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};" Else - connectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True" + oConnectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True" End If + Case Else _Logger.Warn("Provider {0} nicht unterstützt!", oProvider) End Select + Else _Logger.Info("No entry for Connection-ID: " & pConnectionId.ToString) End If + Catch ex As Exception _Logger.Error(ex) _Logger.Info("Error in bei Get_ConnectionStringforID") End Try - Return connectionString + + Return DecryptConnectionString(oConnectionString) End Function