MS HTTPS, Log,
This commit is contained in:
@@ -4,22 +4,23 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class clsDatabase
|
||||
Private Shared MSSQL_inited As Boolean = False
|
||||
Dim Logger As Logger
|
||||
Sub New(MyLogger As LogConfig, ConStr As String)
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
Init(ConStr)
|
||||
End Sub
|
||||
Public Function Init(CONSTRING As String)
|
||||
Public Function Init(CONSTRING As String, pSaveCS As Boolean)
|
||||
Try
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
SQLconnect.ConnectionString = CONSTRING
|
||||
SQLconnect.Open()
|
||||
SQLconnect.Close()
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
MSSQL_inited = True
|
||||
If pSaveCS = True Then
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
|
||||
End If
|
||||
MSSQL_inited = True
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"CONSTRING: {CONSTRING}")
|
||||
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
@@ -219,15 +220,19 @@ Public Class clsDatabase
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Return_Datatable(Select_anweisung As String)
|
||||
Public Function Return_Datatable(Select_anweisung As String, Optional pSQLConnection As String = "")
|
||||
Try
|
||||
Logger.Debug("Select_anweisung: " & Select_anweisung)
|
||||
If MSSQL_inited = False Then Return Nothing
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
SQLcommand.CommandText = Select_anweisung
|
||||
@@ -240,20 +245,30 @@ Public Class clsDatabase
|
||||
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {Select_anweisung}")
|
||||
'clsLogger.Add("Error in Return_Datatable: " & ex.Message, True)
|
||||
'clsLogger.Add(">> SQL: " & Select_anweisung, False)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Function Execute_non_Query(ExecuteCMD As String)
|
||||
Public Function Execute_non_Query(ExecuteCMD As String, Optional pSQLConnection As String = "")
|
||||
If MSSQL_inited = False Then Return False
|
||||
Dim oSQLCON As String
|
||||
Try
|
||||
Logger.Debug("ExecuteCMD: " & ExecuteCMD)
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
oSQLCON = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
oSQLCON = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = oSQLCON
|
||||
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
@@ -268,7 +283,10 @@ Public Class clsDatabase
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Dim msg = $"Unexpected error in Execute_non_Query: SQL: {ExecuteCMD}, oSQLCON: {oSQLCON}"
|
||||
Logger.Error(ex)
|
||||
Logger.Debug(msg)
|
||||
Logger.Info(msg)
|
||||
'clsLogger.Add("Error in Execute_non_Query: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & ExecuteCMD, False)
|
||||
|
||||
@@ -276,7 +294,7 @@ Public Class clsDatabase
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Execute_Scalar(cmdscalar As String)
|
||||
Public Function Execute_Scalar(cmdscalar As String, Optional pSQLConnection As String = "")
|
||||
If MSSQL_inited = False Then Return Nothing
|
||||
Dim result
|
||||
Try
|
||||
@@ -285,7 +303,11 @@ Public Class clsDatabase
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
|
||||
SQLconnect.Open()
|
||||
@@ -300,7 +322,7 @@ Public Class clsDatabase
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {cmdscalar}")
|
||||
'clsLogger.Add("Error in Execute_Scalar: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & cmdscalar, False)
|
||||
Return Nothing
|
||||
|
||||
Reference in New Issue
Block a user