Specifying the Command

From RAD Studio
Jump to: navigation, search

Go Up to Using Command Objects


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.

with ADOCommand1 do begin
  CommandText := "AddEmployee";
  CommandType := cmdStoredProc;
...
end;
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