Public Sub Async_Exec(ByVal myConnection As DbConnectionBase)
Dim myCommand As DbCommandBase = myConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO Customer (DisplayName, Notes) VALUES ('John Smith', 'VIP Customer')"
Console.WriteLine("Starting asynchronous query execution...")
myConnection.Open()
Dim cres As IAsyncResult = myCommand.BeginExecuteNonQuery(Nothing, Nothing)
If cres.IsCompleted Then
Console.WriteLine("Completed.")
Else
Console.WriteLine("Have to wait for operation to complete...")
End If
Try
Dim RowsAffected As Integer = myCommand.EndExecuteNonQuery(cres)
Console.WriteLine(String.Concat("Rows affected: ", RowsAffected.ToString()))
Catch e As Exception
Console.WriteLine(String.Concat("An exception has occurred: ", e.Message))
Finally
myConnection.Close()
End Try
End Sub