Database: Clean up Get_ConnectionStringforID, Version 1.2.1
This commit is contained in:
parent
9346eb9534
commit
fb410d6308
@ -49,41 +49,41 @@ Public Class MSSQLServer
|
||||
|
||||
Return oConnectionStringBuilder.ToString
|
||||
End Function
|
||||
Public Function Get_ConnectionStringforID(pID As Integer)
|
||||
Public Function Get_ConnectionStringforID(pConnectionId As Integer)
|
||||
Dim connectionString As String = ""
|
||||
Try
|
||||
'Me.TBCONNECTIONTableAdapter.FillByID(Me.DD_DMSLiteDataSet.TBCONNECTION, id)
|
||||
Dim oDTConnection As DataTable = GetDatatable("SELECT * FROM TBDD_CONNECTION WHERE GUID = " & pID)
|
||||
Dim oDTConnection As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}")
|
||||
If oDTConnection.Rows.Count = 1 Then
|
||||
Select Case oDTConnection.Rows(0).Item("SQL_PROVIDER").ToString.ToUpper
|
||||
Dim oRow As DataRow = oDTConnection.Rows(0)
|
||||
Dim oProvider = oRow.Item("SQL_PROVIDER").ToString.ToUpper
|
||||
Dim oServer = oRow.Item("SERVER")
|
||||
Dim oDatabase = oRow.Item("DATENBANK")
|
||||
Dim oUser = oRow.Item("USERNAME")
|
||||
Dim oPassword = oRow.Item("PASSWORD")
|
||||
|
||||
Select Case oProvider
|
||||
Case "MS-SQL"
|
||||
If oDTConnection.Rows(0).Item("USERNAME") = "WINAUTH" Then
|
||||
connectionString = "Server=" & oDTConnection.Rows(0).Item("SERVER") & ";Database=" & oDTConnection.Rows(0).Item("DATENBANK") & ";Trusted_Connection=True;"
|
||||
If oUser = "WINAUTH" Then
|
||||
connectionString = $"Server={oServer};Database={oDatabase};Trusted_Connection=True;"
|
||||
Else
|
||||
connectionString = "Server=" & oDTConnection.Rows(0).Item("SERVER") & ";Database=" & oDTConnection.Rows(0).Item("DATENBANK") & ";User Id=" & oDTConnection.Rows(0).Item("USERNAME") & ";Password=" & oDTConnection.Rows(0).Item("USERNAME") & ";Password=" & oDTConnection.Rows(0).Item("PASSWORD") & ";"
|
||||
connectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};"
|
||||
End If
|
||||
' connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
||||
Case "Oracle"
|
||||
If oDTConnection.Rows(0).Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
||||
connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & oDTConnection.Rows(0).Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
||||
oDTConnection.Rows(0).Item("DATENBANK") & ")));User Id=" & oDTConnection.Rows(0).Item("USERNAME") & ";Password=" & oDTConnection.Rows(0).Item("PASSWORD") & ";"
|
||||
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};"
|
||||
Else
|
||||
connectionString = "Data Source=" & oDTConnection.Rows(0).Item("SERVER") & ";Persist Security Info=True;User Id=" & oDTConnection.Rows(0).Item("USERNAME") & ";Password=" & oDTConnection.Rows(0).Item("PASSWORD") & ";Unicode=True"
|
||||
connectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True"
|
||||
End If
|
||||
'Case "ODBC"
|
||||
' Dim conn As New OdbcConnection("dsn=" & DTConnection.Rows(0).Item("SERVER") & ";uid=" & DTConnection.Rows(0).Item("USERNAME") & ";pwd=" + DTConnection.Rows(0).Item("PASSWORD"))
|
||||
' connectionString = conn.ConnectionString
|
||||
Case Else
|
||||
_Logger.Info(" - ConnectionType nicht integriert")
|
||||
_Logger.Warn("Provider {0} nicht unterstützt!", oProvider)
|
||||
|
||||
End Select
|
||||
Else
|
||||
_Logger.Info(" No entry for Connection-ID: " & pID.ToString)
|
||||
_Logger.Info("No entry for Connection-ID: " & pConnectionId.ToString)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Info(" - Error in bei Get ConnectionString - Fehler: " & vbNewLine & ex.Message)
|
||||
_Logger.Info("Error in bei Get_ConnectionStringforID")
|
||||
End Try
|
||||
Return connectionString
|
||||
End Function
|
||||
@ -94,6 +94,7 @@ Public Class MSSQLServer
|
||||
|
||||
Private Function TestCanConnect(ConnectionString As String) As Boolean
|
||||
Try
|
||||
_Logger.Debug("Testing connection to [{0}]", ConnectionString)
|
||||
Dim oConnection As New SqlConnection(ConnectionString)
|
||||
oConnection.Open()
|
||||
oConnection.Close()
|
||||
|
||||
@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Database")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2018")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2021")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.2.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.2.0.1")>
|
||||
<Assembly: AssemblyVersion("1.2.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.2.1.0")>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user