Public Sub Async_Exec(ByVal myConnection As DbConnectionBase)
Dim myCommand As DbCommandBase = myConnection.CreateCommand()
myCommand.CommandText = "SELECT Id, DisplayName, Notes FROM Customer"
Console.WriteLine("Starting asynchronous retrieval of data...")
myConnection.Open()
Dim cres As IAsyncResult = myCommand.BeginExecuteReader(Nothing, Nothing)
If cres.IsCompleted Then
Console.WriteLine("Completed.")
Else
Console.WriteLine("Have to wait for operation to complete...")
End If
Dim myReader As DbDataReader = myCommand.EndExecuteReader(cres)
Try
While myReader.Read()
Console.WriteLine(String.Concat(myReader.GetString(0), " ", myReader.GetString(1), " ", myReader.GetString(2)))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
End Sub