RAD Studio |  |

Specifying the Command
See Also
Collapse All

Specify commands for a TADOCommand component using the CommandText property. Like TADODataSet, TADOCommand lets you specify the command in different ways, depending on the CommandType property. Possible values for CommandType include: cmdText (used if the command is an SQL statement), cmdTable (if it is a table name), and cmdStoredProc (if the command is the name of a stored procedure). At design-time, select the appropriate command type from the list in the Object Inspector. At runtime, assign a value of type TCommandType to the CommandType property.

Copy Code

    with ADOCommand1 do begin
      CommandText := "AddEmployee";
      CommandType := cmdStoredProc;
    ...
    end;

Copy Code

    ADOCommand1->CommandText = "AddEmployee";
    ADOCommand1->CommandType = cmdStoredProc;
    ...

If no specific type is specified, the server is left to decide as best it can based on the command in CommandText.

CommandText can contain the text of an SQL query that includes parameters or the name of a stored procedure that uses parameters. You must then supply parameter values, which are bound to the parameters before executing the command. See Handling command parameters for details.

See Also

Using the Execute Method

Canceling Commands

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!