jj_01_02_16
This commit is contained in:
@@ -114,6 +114,40 @@ Public Class ClassDatabase
|
||||
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.BeginExecuteNonQuery(callback, SQLcommand)
|
||||
Catch ex As Exception
|
||||
If Userinput = True Then
|
||||
MsgBox("Fehler bei Execute_non_Query_Async: " & ex.Message & vbNewLine & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical)
|
||||
End If
|
||||
ClassLogger.Add("Fehler bei 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 Userinput As Boolean = False)
|
||||
Dim result
|
||||
Try
|
||||
|
||||
Reference in New Issue
Block a user