2.4.1.7 Logging SQL from Task, replacing '
This commit is contained in:
@@ -7,7 +7,7 @@ Public Class ClassDatabase
|
||||
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)
|
||||
Dim DTConnection As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM TBDD_CONNECTION WHERE GUID = " & id, "Get_ConnectionString")
|
||||
If DTConnection.Rows.Count = 1 Then
|
||||
Select Case DTConnection.Rows(0).Item("SQL_PROVIDER").ToString.ToUpper
|
||||
Case "MS-SQL"
|
||||
@@ -57,36 +57,42 @@ Public Class ClassDatabase
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function Return_Datatable(Select_anweisung As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Return_Datatable(pSQLCommand As String, Optional pInfo As String = "")
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
LOGGER.Debug("ReturnDatatable: " & Select_anweisung)
|
||||
LOGGER.Debug($"Return_Datatable[{pSQLCommand}]#{pInfo}")
|
||||
SQLconnect.ConnectionString = SQLSERVERConnectionString
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
SQLcommand.CommandText = Select_anweisung
|
||||
LOGGER.Debug("Execute ReturnDatatable: " & Select_anweisung)
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
LOGGER.Debug("Execute ReturnDatatable: " & pSQLCommand)
|
||||
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand)
|
||||
Dim dt As DataTable = New DataTable()
|
||||
adapter1.Fill(dt)
|
||||
SQLconnect.Close()
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable: {ex.Message} [{Select_anweisung}]")
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Return_Datatable_ConId(SQLCommand As String, ConnID As Integer, Optional userInput As Boolean = False)
|
||||
Public Shared Function Return_Datatable_ConId(pSQLCommand As String, ConnID As Integer, Optional pInfo As String = "")
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim oConnString = Get_ConnectionString(ConnID)
|
||||
LOGGER.Debug($"Return_Datatable_ConId [{ConnID}]: " & SQLCommand)
|
||||
LOGGER.Debug($"Return_Datatable_ConId [{ConnID}]#[{pSQLCommand}]#{pInfo}")
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
Dim oSQLcommand As SqlClient.SqlCommand
|
||||
oSQLconnect.ConnectionString = oConnString
|
||||
oSQLconnect.Open()
|
||||
oSQLcommand = oSQLconnect.CreateCommand
|
||||
oSQLcommand.CommandText = SQLCommand
|
||||
oSQLcommand.CommandText = pSQLCommand
|
||||
|
||||
Dim oSQLAdapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(oSQLcommand)
|
||||
Dim oReturnDatatable As DataTable = New DataTable()
|
||||
@@ -94,22 +100,23 @@ Public Class ClassDatabase
|
||||
oSQLconnect.Close()
|
||||
Return oReturnDatatable
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable_ConId: {ex.Message} [{SQLCommand}]")
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Return_Datatable_ConId - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & SQLCommand, MsgBoxStyle.Critical)
|
||||
End If
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable_ConId{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Return_Datatable_ConStr(SQLCommand As String, ConNStr As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Return_Datatable_ConStr(pSQLCommand As String, ConNStr As String, Optional pInfo As String = "")
|
||||
Try
|
||||
LOGGER.Debug("Return_Datatable_ConStr: " & SQLCommand)
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
LOGGER.Debug("Return_Datatable_ConStr: " & pSQLCommand)
|
||||
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
Dim oSQLcommand As SqlClient.SqlCommand
|
||||
oSQLconnect.ConnectionString = ConNStr
|
||||
oSQLconnect.Open()
|
||||
oSQLcommand = oSQLconnect.CreateCommand
|
||||
oSQLcommand.CommandText = SQLCommand
|
||||
oSQLcommand.CommandText = pSQLCommand
|
||||
|
||||
Dim oSQLAdapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(oSQLcommand)
|
||||
Dim oReturnDatatable As DataTable = New DataTable()
|
||||
@@ -117,68 +124,60 @@ Public Class ClassDatabase
|
||||
oSQLconnect.Close()
|
||||
Return oReturnDatatable
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable_ConStr: {ex.Message} [{SQLCommand}]")
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Return_Datatable_ConStr - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & SQLCommand, MsgBoxStyle.Critical)
|
||||
End If
|
||||
LOGGER.Warn($"Unexpected Error in Return_Datatable_ConStr{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Execute_non_Query(ExecuteCMD As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Execute_non_Query(pSQLCommand As String, Optional pInfo As String = "")
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = SQLSERVERConnectionString
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
'Update Last Created Record in Foo
|
||||
SQLcommand.CommandText = ExecuteCMD
|
||||
LOGGER.Debug("Execute_non_Query Created: " & ExecuteCMD)
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
LOGGER.Debug("Execute_non_Query Created: " & pSQLCommand)
|
||||
SQLcommand.ExecuteNonQuery()
|
||||
SQLcommand.Dispose()
|
||||
SQLconnect.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
||||
End If
|
||||
Clipboard.SetText("Error ExecuteCMD: " & ex.Message & vbNewLine & "SQL: " & ExecuteCMD)
|
||||
LOGGER.Info("Fehler bei Execute_non_Query: " & ex.Message, True)
|
||||
LOGGER.Info("#SQL: " & ExecuteCMD, False)
|
||||
|
||||
LOGGER.Warn($"Unexpected Error in Execute_non_Query{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Execute_non_Query_ConStr(ExecuteCMD As String, ConnString As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Execute_non_Query_ConStr(pSQLCommand As String, ConnString As String, Optional pInfo As String = "")
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = ConnString
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
'Update Last Created Record in Foo
|
||||
SQLcommand.CommandText = ExecuteCMD
|
||||
LOGGER.Debug("Execute_non_Query_ConStr Created: " & ExecuteCMD)
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
LOGGER.Debug("Execute_non_Query_ConStr Created: " & pSQLCommand)
|
||||
SQLcommand.ExecuteNonQuery()
|
||||
SQLcommand.Dispose()
|
||||
SQLconnect.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Execute_non_Query_ConStr - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
||||
End If
|
||||
Clipboard.SetText("Error Execute_non_Query_ConStr: " & ex.Message & vbNewLine & "SQL: " & ExecuteCMD)
|
||||
LOGGER.Info("Fehler bei Execute_non_Query_ConStr: " & ex.Message, True)
|
||||
LOGGER.Info("#SQL: " & ExecuteCMD, False)
|
||||
|
||||
LOGGER.Warn($"Unexpected Error in Execute_non_Query_ConStr{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Execute_Scalar(cmdscalar As String, ConString As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Execute_Scalar(pSQLCommand As String, ConString As String, Optional pInfo As String = "")
|
||||
Dim result
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = ConString
|
||||
@@ -186,74 +185,61 @@ Public Class ClassDatabase
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
'Update Last Created Record in Foo
|
||||
SQLcommand.CommandText = cmdscalar
|
||||
LOGGER.Debug("Execute_Scalar: " & cmdscalar)
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
LOGGER.Debug("Execute_Scalar: " & pSQLCommand)
|
||||
result = SQLcommand.ExecuteScalar()
|
||||
SQLcommand.Dispose()
|
||||
SQLconnect.Close()
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Execute Scalar - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & cmdscalar, MsgBoxStyle.Critical)
|
||||
End If
|
||||
Clipboard.SetText("Error Execute_Scalar: " & ex.Message & vbNewLine & "SQL: " & cmdscalar)
|
||||
LOGGER.Info("Fehler bei Execute_Scalar: " & ex.Message, True)
|
||||
LOGGER.Info("#SQL: " & cmdscalar, False)
|
||||
LOGGER.Warn($"Unexpected Error in Execute_Scalar{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Execute_Scalar_ConStr(cmdscalar As String, ConString As String, Optional userInput As Boolean = False)
|
||||
Public Shared Function Execute_Scalar_ConStr(pSQLCommand As String, ConString As String, Optional pInfo As String = "")
|
||||
Dim result
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = ConString
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
'Update Last Created Record in Foo
|
||||
SQLcommand.CommandText = cmdscalar
|
||||
LOGGER.Debug("Execute_Scalar_ConStr Scalar: " & cmdscalar)
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
LOGGER.Debug("Execute_Scalar_ConStr Scalar: " & pSQLCommand)
|
||||
result = SQLcommand.ExecuteScalar()
|
||||
SQLcommand.Dispose()
|
||||
SQLconnect.Close()
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Execute_Scalar_ConStr - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & cmdscalar, MsgBoxStyle.Critical)
|
||||
End If
|
||||
Clipboard.SetText("Error Execute_Scalar_ConStr: " & ex.Message & vbNewLine & "SQL: " & cmdscalar)
|
||||
LOGGER.Info("Fehler bei Execute_Scalar_ConStr: " & ex.Message, True)
|
||||
LOGGER.Info("#SQL: " & cmdscalar, False)
|
||||
LOGGER.Warn($"Unexpected Error in Execute_Scalar_ConStr{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Execute_Scalar_ConID(cmdscalar As String, ConnID As Integer, Optional userInput As Boolean = False)
|
||||
Public Shared Function Execute_Scalar_ConID(pSQLCommand As String, ConnID As Integer, Optional pInfo As String = "")
|
||||
Dim result
|
||||
Try
|
||||
If pInfo <> "" Then
|
||||
pInfo = "[" & pInfo & "]"
|
||||
End If
|
||||
Dim oConnString = Get_ConnectionString(ConnID)
|
||||
LOGGER.Debug($"Execute_Scalar_ConID [{ConnID}]: " & cmdscalar)
|
||||
|
||||
LOGGER.Debug($"Execute_Scalar_ConID [{ConnID}]: " & pSQLCommand)
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = oConnString
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
'Update Last Created Record in Foo
|
||||
SQLcommand.CommandText = cmdscalar
|
||||
SQLcommand.CommandText = pSQLCommand
|
||||
result = SQLcommand.ExecuteScalar()
|
||||
SQLcommand.Dispose()
|
||||
SQLconnect.Close()
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
If userInput = True Then
|
||||
MsgBox("Error in Execute_Scalar_ConStr - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & cmdscalar, MsgBoxStyle.Critical)
|
||||
End If
|
||||
Clipboard.SetText("Error Execute_Scalar_ConStr: " & ex.Message & vbNewLine & "SQL: " & cmdscalar)
|
||||
LOGGER.Info("Fehler bei Execute_Scalar_ConStr: " & ex.Message, True)
|
||||
LOGGER.Info("#SQL: " & cmdscalar, False)
|
||||
LOGGER.Warn($"Unexpected Error in Execute_Scalar_ConID{pInfo}: {ex.Message} [{pSQLCommand}]")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Reference in New Issue
Block a user