RAD Studio |  |

Canceling Commands
See Also
Collapse All

If you are executing the command asynchronously, then after calling Execute you can abort the execution by calling the Cancel method:

Copy Code

    procedure TDataForm.ExecuteButtonClick(Sender: TObject);
    begin
      ADOCommand1.Execute;
    end;
    procedure TDataForm.CancelButtonClick(Sender: TObject);
    begin
      ADOCommand1.Cancel;
    end;

Copy Code

    void __fastcall TDataForm::ExecuteButtonClick(TObject *Sender)
    {
      ADOCommand1->Execute();
    }
    void __fastcall TDataForm::CancelButtonClick(TObject *Sender)
    {
      ADOCommand1->Cancel();
    }

The Cancel method only has an effect if there is a command pending and it was executed asynchronously (eoAsynchExecute is in the ExecuteOptions parameter of the Execute method). A command is said to be pending if the Execute method has been called but the command has not yet been completed or timed out.

A command times out if it is not completed or canceled before the number of seconds specified in the CommandTimeout property expire. By default, commands time out after 30 seconds.

See Also

Specifying the Command

Using the Execute Method

Retrieving Result Sets with Commands

Handling Command Parameters

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!