

M圜ommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')"Ĭonsole.WriteLine( "Starting asynchronous query execution.")ĭim cres As IAsyncResult = m圜ommand.BeginExecuteNonQuery( Nothing, Nothing)Ĭonsole.WriteLine( "Have to wait for operation to complete.")Įnd If Try Dim RowsAffected As Integer = m圜ommand.EndExecuteNonQuery(cres)Ĭonsole.WriteLine( String.Concat( "Rows affected: ", RowsAffected.ToString()))Ĭonsole.WriteLine( String.Concat( "An exception has occurred: ", e.Message))

If a callback procedure was specified in the call to BeginExecuteNonQuery, this method must be called.Public Sub Async_Exec( ByVal m圜onnection As DbConnectionBase)ĭim m圜ommand As DbCommandBase = m圜onnection.CreateCommand() Users can verify that the command has completed its operation by using the IAsyncResult instance returned by the BeginExecuteNonQuery method. If the process of executing the command has not yet finished, this method blocks until the operation is complete. When you call BeginExecuteNonQuery to execute a Transact-SQL statement, you must call EndExecuteNonQuery in order to complete the operation. Examplesįor examples demonstrating the use of the EndExecuteNonQuery method, see BeginExecuteNonQuery. To correct this situation, you should either increase the value of CommandTimeout or reduce the work being done by the asynchronous operation. If this occurs and EndExecuteNonQuery(IAsyncResult) is called, EndExecuteNonQuery could raise a SqlException error if the amount of time specified in CommandTimeout elapsed and the asynchronous operation specified with BeginExecuteNonQuery is not complete. In some situations, IAsyncResult can be set to IsCompleted incorrectly.

The amount of time specified in CommandTimeout elapsed and the asynchronous operation specified with BeginExecuteNonQuery is not complete.
