This commit is contained in:
2026-07-19 23:30:33 +02:00
parent 718115a1e4
commit cf75d131cc
12 changed files with 1273 additions and 778 deletions

View File

@@ -1070,7 +1070,7 @@ Public Class SQL
End Function
Public Function loadDgvBySql_Param(ByVal sql As String, Optional conn_art As String = "SDL", Optional timeout As Integer = 0, Optional list As List(Of SQLVariable) = Nothing, Optional showErr As Boolean = True, Optional ByRef errOccured As Boolean = False) As DataTable
Public Function loadDgvBySql_Param(ByVal sql As String, Optional conn_art As String = "SDL", Optional timeout As Integer = 0, Optional list As List(Of SQLVariable) = Nothing, Optional showErr As Boolean = True, Optional ByRef errOccured As Boolean = False, Optional ByRef maxVersuche As Integer = 3) As DataTable
Try
Dim myTable = New DataTable()
Dim conn As New SqlConnection
@@ -1088,20 +1088,46 @@ Public Class SQL
Case "WEB" : conn = GetNewOpenConnectionWEB()
End Select
' Using conn As SqlConnection = GetNewOpenConnection()
Using cmd As New SqlCommand(sql, conn)
If list IsNot Nothing Then
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))
Next
End If
If timeout > 0 Then cmd.CommandTimeout = timeout
Dim dr As SqlDataReader = cmd.ExecuteReader()
Dim versuch As Integer = 0
Do
versuch += 1
Try
Using cmd As New SqlCommand(sql, conn)
If list IsNot Nothing Then
For Each i In list
cmd.Parameters.AddWithValue("@" & i.Scalarvariable.Trim, If(i.Value Is Nothing, DBNull.Value, i.Value))
Next
End If
If timeout > 0 Then cmd.CommandTimeout = timeout
Using dr As SqlDataReader = cmd.ExecuteReader()
myTable.Load(dr)
End Using
End Using
Exit Do ' Erfolgreich
Catch ex As SqlException When ex.Number = 1205 AndAlso versuch < maxVersuche
If versuch >= maxVersuche Then Throw
Threading.Thread.Sleep(200 * versuch)
End Try
Loop
'' Using conn As SqlConnection = GetNewOpenConnection()
'Using cmd As New SqlCommand(sql, conn)
'If list IsNot Nothing Then
' 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))
' Next
'End If
'If timeout > 0 Then cmd.CommandTimeout = timeout
'Dim dr As SqlDataReader = cmd.ExecuteReader()
'myTable.Load(dr)
' dr.Close()
myTable.Load(dr)
dr.Close()
End Using
conn.Close()
' End Using
Return myTable 'While Schleife wird hier verlassen