Public Sub Async_Exec(ByVal myConnection As DbConnectionBase)
Dim myCommand As DbCommandBase = myConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO Folders(Name, Type) VALUES ('Sales', 'campaign')"
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