494 lines
22 KiB
VB.net
494 lines
22 KiB
VB.net
Imports Oracle.ManagedDataAccess.Client
|
|
Imports System.Data.Odbc
|
|
Imports System.Data.SqlClient
|
|
|
|
Public Class ClassDatabase
|
|
Private Shared connectionString As String
|
|
|
|
Public Shared Function Init()
|
|
Try
|
|
connectionString = MyConnectionString
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLconnect.Close()
|
|
Return True
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
|
|
Public Shared Function GetConnectionString(id As Integer)
|
|
Dim connectionString As String = ""
|
|
Try
|
|
'Me.TBCONNECTIONTableAdapter.FillByID(Me.DD_DMSLiteDataSet.TBCONNECTION, id)
|
|
Dim DTConnection As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM TBDD_CONNECTION WHERE GUID = " & id, True)
|
|
If DTConnection.Rows.Count = 1 Then
|
|
Select Case DTConnection.Rows(0).Item("SQL_PROVIDER")
|
|
Case "MS-SQL"
|
|
If DTConnection.Rows(0).Item("USERNAME") = "WINAUTH" Then
|
|
connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";Trusted_Connection=True;"
|
|
Else
|
|
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("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
|
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 "MS-SQLServer"
|
|
If DTConnection.Rows(0).Item("USERNAME") = "WINAUTH" Then
|
|
connectionString = "Server=" & DTConnection.Rows(0).Item("SERVER") & ";Database=" & DTConnection.Rows(0).Item("DATENBANK") & ";Trusted_Connection=True;"
|
|
Else
|
|
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("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
|
End If
|
|
Case "Oracle"
|
|
If DTConnection.Rows(0).Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
|
connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & DTConnection.Rows(0).Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
|
DTConnection.Rows(0).Item("DATENBANK") & ")));User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";"
|
|
Else
|
|
connectionString = "Data Source=" & DTConnection.Rows(0).Item("SERVER") & ";Persist Security Info=True;User Id=" & DTConnection.Rows(0).Item("USERNAME") & ";Password=" & DTConnection.Rows(0).Item("PASSWORD") & ";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
|
|
ClassLogger.Add(" - ConnectionType nicht integriert", False)
|
|
MsgBox("ConnectionType nicht integriert", MsgBoxStyle.Critical, "Bitte Konfiguration Connection überprüfen!")
|
|
End Select
|
|
Else
|
|
ClassLogger.Add(" No entry for Connection-ID: " & id.ToString, True)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ClassLogger.Add(" - Error in bei GetConnectionString - Fehler: " & vbNewLine & ex.Message)
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in GetConnectionString:")
|
|
End Try
|
|
Return connectionString
|
|
End Function
|
|
Public Shared Function Return_Datatable(Select_anweisung As String, Optional USE_PROXY As Boolean = False)
|
|
Try
|
|
Dim sw As New SW("Return_Datatable: " & Select_anweisung)
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
|
|
If USE_PROXY = True And DD_LIB_Standards.clsDatabase.DB_PROXY_INITIALIZED Then
|
|
SQLconnect.ConnectionString = ClassProxy.MyPROXYConnectionString
|
|
Else
|
|
SQLconnect.ConnectionString = connectionString
|
|
End If
|
|
|
|
If USE_PROXY = False Then
|
|
Console.WriteLine(Select_anweisung)
|
|
End If
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
SQLcommand.CommandText = Select_anweisung
|
|
SQLcommand.CommandTimeout = 180
|
|
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand)
|
|
Dim dt As DataTable = New DataTable()
|
|
|
|
adapter1.Fill(dt)
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return dt
|
|
Catch ex As Exception
|
|
MsgBox("Error in Return_Datatable: " & ex.Message & vbNewLine & vbNewLine & Select_anweisung, MsgBoxStyle.Critical)
|
|
ClassHelper.InsertEssential_Log(CURRENT_RECORD_ID, "RECORD-ID", ex.Message & " - SQL: " & Select_anweisung)
|
|
ClassLogger.Add("Error in Return_Datatable: " & ex.Message, True)
|
|
ClassLogger.Add(">> SQL: " & Select_anweisung, False)
|
|
If (ex.Message.Contains("Ungültiger Objektname") Or ex.Message.Contains("Invalid Object Name")) And DD_LIB_Standards.clsDatabase.DB_PROXY_INITIALIZED Then
|
|
MsgBox("A database-object could not be found but synchronization of Proxyserver might be in action! So please try again in a few seconds/minutes!", MsgBoxStyle.Exclamation)
|
|
End If
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function MSSQL_ReturnDTWithConnection(connectionId As Integer, sql As String)
|
|
Try
|
|
Dim regex As New System.Text.RegularExpressions.Regex("(@(\d+)@)")
|
|
Dim match As System.Text.RegularExpressions.Match = regex.Match(sql)
|
|
|
|
If match.Success Then
|
|
'Return Nothing
|
|
End If
|
|
|
|
Dim connectionString As String
|
|
connectionString = ClassDatabase.GetConnectionString(connectionId)
|
|
If connectionString <> "" Then
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
SQLcommand.CommandText = sql
|
|
|
|
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand)
|
|
Dim dt As DataTable = New DataTable()
|
|
adapter1.Fill(dt)
|
|
SQLconnect.Close()
|
|
Return dt
|
|
Else
|
|
MsgBox("No Connection received for ID: " & connectionId.ToString, MsgBoxStyle.Exclamation)
|
|
Return Nothing
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Unexpected Error in MSSQL_ReturnDTWithConnection: " & vbNewLine & ex.Message & vbNewLine & vbNewLine & sql)
|
|
MsgBox("Unexpected Error in MSSQL_ReturnDTWithConnection:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & sql, MsgBoxStyle.Critical)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function Return_Datatable_CS(Select_anweisung As String, ConString As String, Optional userInput As Boolean = False)
|
|
Try
|
|
Dim sw As New SW("Return_Datatable_CS: " & Select_anweisung)
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = ConString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
SQLcommand.CommandText = Select_anweisung
|
|
|
|
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand)
|
|
Dim dt As DataTable = New DataTable()
|
|
adapter1.Fill(dt)
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return dt
|
|
Catch ex As Exception
|
|
If userInput = True Then
|
|
MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & Select_anweisung, MsgBoxStyle.Critical)
|
|
End If
|
|
ClassLogger.Add("Error in Return_Datatable_CS: " & ex.Message, True)
|
|
ClassLogger.Add("#SQL: " & Select_anweisung, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function Return_Datatable_Connection(Select_anweisung As String, connectionId As Integer, Optional userInput As Boolean = False)
|
|
Try
|
|
Dim sw As New SW("Return_Datatable_Connection: " & Select_anweisung)
|
|
Dim connectionString As String
|
|
connectionString = ClassDatabase.GetConnectionString(connectionId)
|
|
If connectionString <> "" Then
|
|
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
SQLcommand.CommandText = Select_anweisung
|
|
|
|
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand)
|
|
Dim dt As DataTable = New DataTable()
|
|
adapter1.Fill(dt)
|
|
SQLconnect.Close()
|
|
sw.Done()
|
|
|
|
Return dt
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
If userInput = True Then
|
|
MsgBox("Error in Return_Datatable_Connection - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & Select_anweisung, MsgBoxStyle.Critical)
|
|
End If
|
|
ClassLogger.Add("Error in Return_Datatable_Connection: " & ex.Message)
|
|
ClassLogger.Add("#SQL: " & Select_anweisung)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function Execute_non_Query(ExecuteCMD As String, Optional USE_PROXY As Boolean = False)
|
|
Try
|
|
Dim sw As New SW("Execute_non_Query: " & ExecuteCMD)
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
If USE_PROXY = True And DD_LIB_Standards.clsDatabase.DB_PROXY_INITIALIZED Then
|
|
SQLconnect.ConnectionString = ClassProxy.MyPROXYConnectionString
|
|
Else
|
|
SQLconnect.ConnectionString = connectionString
|
|
End If
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = ExecuteCMD
|
|
SQLcommand.CommandTimeout = 120
|
|
SQLcommand.ExecuteNonQuery()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return True
|
|
Catch ex As Exception
|
|
'If Userinput = True Then
|
|
' MsgBox("Error in Execute_non_Query: " & ex.Message & vbNewLine & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
|
'End If
|
|
ClassLogger.Add("Error in Execute_non_Query: " & ex.Message)
|
|
ClassLogger.Add("SQL: " & ExecuteCMD)
|
|
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
Public Shared Function Execute_non_Query_withConn(ExecuteCMD As String, ConnID As Integer)
|
|
Try
|
|
Dim sw As New SW("Execute_non_Query_withConn: " & ExecuteCMD)
|
|
|
|
Dim connectionString As String
|
|
connectionString = ClassDatabase.GetConnectionString(ConnID)
|
|
If connectionString <> "" Then
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = ExecuteCMD
|
|
SQLcommand.CommandTimeout = 120
|
|
SQLcommand.ExecuteNonQuery()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return True
|
|
Else
|
|
MsgBox("No ConnectionID for Conn-ID: " & ConnID.ToString, MsgBoxStyle.Exclamation)
|
|
Return Nothing
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in Execute_non_Query_withConn: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & ExecuteCMD, False)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
Public Shared Function Execute_non_Query_withConnString(ExecuteCMD As String, theconnstring As String)
|
|
Try
|
|
Dim sw As New SW("Execute_non_Query_withConnString: " & ExecuteCMD)
|
|
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = theconnstring
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = ExecuteCMD
|
|
SQLcommand.CommandTimeout = 120
|
|
SQLcommand.ExecuteNonQuery()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return True
|
|
|
|
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in Execute_non_Query_withConnString: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & ExecuteCMD, False)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
'TODO: Asynchrone Abfrage möglich machen
|
|
Public Shared Sub Execute_non_Query_Async(ExecuteCMD As String, Optional Userinput As Boolean = False)
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback)
|
|
|
|
Try
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand()
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = ExecuteCMD
|
|
SQLcommand.CommandTimeout = 120
|
|
|
|
SQLcommand.BeginExecuteNonQuery(callback, SQLcommand)
|
|
Catch ex As Exception
|
|
If Userinput = True Then
|
|
MsgBox("Error in Execute_non_Query_Async: " & ex.Message & vbNewLine & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
|
End If
|
|
ClassLogger.Add("Error in Execute_non_Query_Async: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & ExecuteCMD, False)
|
|
Finally
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Shared Sub Execute_non_Query_Async_Callback(ByVal result As IAsyncResult)
|
|
Dim command As SqlClient.SqlCommand = CType(result.AsyncState, SqlClient.SqlCommand)
|
|
Dim res = command.EndExecuteNonQuery(result)
|
|
|
|
ClassLogger.Add(String.Format("Finished executing Async database operation: {0}", command.CommandText), False)
|
|
End Sub
|
|
|
|
Public Shared Function Execute_Scalar(cmdscalar As String, Optional USE_PROXY As Boolean = False)
|
|
Dim result
|
|
Try
|
|
Dim sw As New SW("Execute_Scalar: " & cmdscalar)
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
If USE_PROXY = True And DD_LIB_Standards.clsDatabase.DB_PROXY_INITIALIZED Then
|
|
SQLconnect.ConnectionString = ClassProxy.MyPROXYConnectionString
|
|
Else
|
|
SQLconnect.ConnectionString = connectionString
|
|
End If
|
|
If USE_PROXY = False Then
|
|
Console.WriteLine(cmdscalar)
|
|
End If
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = cmdscalar
|
|
SQLcommand.CommandTimeout = 120
|
|
result = SQLcommand.ExecuteScalar()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
|
|
sw.Done()
|
|
|
|
Return result
|
|
Catch ex As Exception
|
|
'If Userinput = True Then
|
|
' MsgBox("Error in Execute_Scalar: " & ex.Message & vbNewLine & vbNewLine & cmdscalar, MsgBoxStyle.Critical)
|
|
'End If
|
|
ClassLogger.Add("Error in Execute_Scalar: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & cmdscalar, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
|
|
Public Shared Function Execute_ScalarWithConnection(connectionId As Integer, cmdscalar As String)
|
|
Dim result
|
|
Try
|
|
Dim connectionString As String
|
|
connectionString = ClassDatabase.GetConnectionString(connectionId)
|
|
If connectionString <> "" Then
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = cmdscalar
|
|
SQLcommand.CommandTimeout = 120
|
|
result = SQLcommand.ExecuteScalar()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
Return result
|
|
Else
|
|
MsgBox("No Connection for ID: " & connectionId & " - ExecuteScalar: " & cmdscalar, MsgBoxStyle.Exclamation)
|
|
ClassLogger.Add("No Connection for ID: " & connectionId & " - ExecuteScalar: " & cmdscalar)
|
|
Return Nothing
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in Execute_ScalarWithConnection: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & cmdscalar, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function Execute_ScalarWithConnectionString(connectionString As String, cmdscalar As String)
|
|
Dim result
|
|
Try
|
|
|
|
Dim SQLconnect As New SqlClient.SqlConnection
|
|
Dim SQLcommand As SqlClient.SqlCommand
|
|
SQLconnect.ConnectionString = connectionString
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = cmdscalar
|
|
SQLcommand.CommandTimeout = 120
|
|
result = SQLcommand.ExecuteScalar()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
Return result
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in Execute_ScalarWithConnectionString: " & ex.Message, True)
|
|
ClassLogger.Add("SQL: " & cmdscalar, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
|
|
Public Shared Function OracleExecute_Scalar(cmdscalar As String, OracleConnection As String)
|
|
Dim result
|
|
Try
|
|
Dim SQLconnect As New OracleConnection
|
|
Dim SQLcommand As New OracleCommand
|
|
SQLconnect.ConnectionString = OracleConnection
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = cmdscalar
|
|
result = SQLcommand.ExecuteScalar()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
Return result
|
|
Catch ex As Exception
|
|
ClassLogger.Add("Error in OracleExecute_Scalar: " & ex.Message, True)
|
|
ClassLogger.Add("#SQL: " & cmdscalar, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
Public Shared Function OracleExecute_non_Query(ExecuteCMD As String, OracleConnection As String, Optional userInput As Boolean = False)
|
|
Try
|
|
Dim SQLconnect As New OracleConnection
|
|
Dim SQLcommand As OracleCommand
|
|
SQLconnect.ConnectionString = OracleConnection
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
'Update Last Created Record in Foo
|
|
SQLcommand.CommandText = ExecuteCMD
|
|
SQLcommand.ExecuteNonQuery()
|
|
SQLcommand.Dispose()
|
|
SQLconnect.Close()
|
|
Return True
|
|
Catch ex As Exception
|
|
If userInput = True Then
|
|
MsgBox("Error in OracleExecute_non_Query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
|
End If
|
|
ClassLogger.Add("Error in OracleExecute_non_Query: " & ex.Message, True)
|
|
ClassLogger.Add("#SQL: " & ExecuteCMD, False)
|
|
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
Public Shared Function Oracle_Return_Datatable(Select_anweisung As String, OracleConnection As String, Optional userInput As Boolean = False)
|
|
Try
|
|
Dim SQLconnect As New OracleConnection
|
|
Dim SQLcommand As OracleCommand
|
|
SQLconnect.ConnectionString = OracleConnection
|
|
SQLconnect.Open()
|
|
SQLcommand = SQLconnect.CreateCommand
|
|
SQLcommand.CommandText = Select_anweisung
|
|
|
|
Dim adapter1 As OracleDataAdapter = New OracleDataAdapter(SQLcommand)
|
|
Dim dt As DataTable = New DataTable()
|
|
adapter1.Fill(dt)
|
|
SQLconnect.Close()
|
|
Return dt
|
|
Catch ex As Exception
|
|
If userInput = True Then
|
|
MsgBox("Error in Oracle Return Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & Select_anweisung, MsgBoxStyle.Critical)
|
|
End If
|
|
ClassLogger.Add("Error in Oracle_Return_Datatable: " & ex.Message, True)
|
|
ClassLogger.Add("#SQL: " & Select_anweisung, False)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
End Class
|