CBAM Rechner

This commit is contained in:
2025-12-19 09:11:05 +01:00
parent d1c23ac18c
commit 29eb8afbe6
11 changed files with 725 additions and 176 deletions

View File

@@ -54,6 +54,9 @@ Public Class SQL
Else
Try
If VERAG_PROG_ALLGEMEIN.cAllgemein.SQLGUIDE01_USED Then
Return My.MySettings.Default.VERAGConnectionStringPROD
End If
Return My.MySettings.Default.FMZOLL_PRODConnectionString
Catch ex As Exception
' Return "Data Source=192.168.0.91\SQLFMZOLL;Initial Catalog=VERAG;Integrated Security=false;User ID=test;Password=BmWr501956;"
@@ -919,51 +922,7 @@ Public Class SQL
Case "PARKZEIT" : conn = GetNewOpenConnectionPARKZEIT()
End Select
'NOT Working--------------------------------------------
'Try
' ' MsgBox(sql)
' Using cmd As New SqlCommand(sql, conn)
' If list IsNot Nothing Then
' For Each i In list
' If String.IsNullOrWhiteSpace(i.Scalarvariable) Then
' Throw New Exception("❌ Leerer Parametername in SQLVariable!")
' End If
' If i.Scalarvariable.ToLower = "errno" Then
' Throw New Exception("❌ Ungültiger Parametername 'errno' bitte umbenennen.")
' End If
' If Not System.Text.RegularExpressions.Regex.IsMatch(i.Scalarvariable, "^[a-zA-Z0-9_]+$") Then
' Throw New Exception("❌ Ungültiger SQL-Parametername (Regex): '" & i.Scalarvariable & "'")
' End If
' 'MsgBox(i.Text.trim & " " & IIf(i.Value Is Nothing, DBNull.Value, i.Value))
' cmd.Parameters.AddWithValue("@" & i.Scalarvariable.trim, IIf(i.Value Is Nothing, DBNull.Value, i.Value))
' Next
' End If
' cmd.ExecuteNonQuery()
' End Using
' conn.Close()
' Return True
'Catch ex As Exception
' ' MsgBox("ERR!")
' If ex.Message.Contains("Falsche Syntax in der Nähe von '@errno'") Then
' ' Spezielle Behandlung für den Fehler mit dem Parameter 'errno'
' 'VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR("❌ Ungültiger SQL-Parametername 'errno' bitte umbenennen.", ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name, , , , , sql)
' ElseIf ex.Message.Contains("Leerer Parametername") Then
' If showErr Then VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name, , , , , sql)
' End If
'End Try
'Return False
'NOT Working--------------------------------------------
Try
' MsgBox(sql)
@@ -972,6 +931,12 @@ Public Class SQL
For Each i In list
'MsgBox(i.Text.trim & " " & IIf(i.Value Is Nothing, DBNull.Value, i.Value))
cmd.Parameters.AddWithValue("@" & i.Scalarvariable.trim, IIf(i.Value Is Nothing, DBNull.Value, i.Value))
'Dim p As SqlParameter = cmd.Parameters.Add(
' "@" & i.Scalarvariable.Trim,
' SqlDbType.Variant
')
'p.Value = If(i.Value Is Nothing, DBNull.Value, i.Value)
Next
End If
cmd.ExecuteNonQuery()
@@ -1028,16 +993,20 @@ Public Class SQL
Else
cmd.ExecuteNonQuery()
'If id <= 0 Then
' Dim newcmd As New SqlCommand("SELECT CONVERT(int,isnull(@@IDENTITY,0))", conn)
' id = CInt(newcmd.ExecuteScalar)
' If id = 0 Then
' Dim newcmd2 As New SqlCommand("SELECT CONVERT(int,isnull(SCOPE_IDENTITY(),0))", conn)
' id = CInt(newcmd2.ExecuteScalar)
' End If
'End If
If id <= 0 Then
Dim newcmd As New SqlCommand("SELECT CONVERT(int,isnull(@@IDENTITY,0))", conn)
id = CInt(newcmd.ExecuteScalar)
If id = 0 Then
Dim newcmd2 As New SqlCommand("SELECT CONVERT(int,isnull(SCOPE_IDENTITY(),0))", conn)
id = CInt(newcmd2.ExecuteScalar)
End If
Using newcmd2 As New SqlCommand("SELECT CONVERT(int, ISNULL(SCOPE_IDENTITY(),0))", conn)
id = CInt(newcmd2.ExecuteScalar())
End Using
End If
End If
'Return True