共用方式為


ICommand::Cancel

Cancels the current command execution.

Syntax

HRESULT Cancel();

Parameters

None.

Return Code

  • S_OK
    The method succeeded.

    The command was not executing.

  • E_FAIL
    A provider-specific error occurred.

  • DB_E_CANTCANCEL
    The executing command cannot be canceled.

Comments

ICommand::Cancel may be called on a separate thread after ICommand::Execute has been called and before the method has returned. If the executing command can be canceled, the method returns S_OK and Execute returns DB_E_CANCELED. If the executing command cannot be canceled, Cancel returns DB_E_CANTCANCEL and Execute continues. If the Execute method has not been called or has already returned, the method returns S_OK.

If the DBPROPVAL_ASYNCH_INITIALIZE bit in the DBPROP_ROWSET_ASYNCH property has been set prior to execution of the command, ICommand::Execute may return with DB_S_ASYNCHRONOUS before the command has fully executed. Calling ICommand::Cancel after the Execute method has returned has no effect on any asynchronously executing commands. Once the Execute method has returned DB_S_ASYNCHRONOUS, the command can be canceled only by calling IDBAsynchStatus::Abort on the returned object.

See Also

Reference

ICommand::Execute