RAD Studio |  |

Executing the Command
See Also
Collapse All

To execute a query or stored procedure that does not return any records, you do not use the Active property or the Open method. Instead, you must use

The ExecSQL method if the dataset is an instance of TSQLDataSet or TSQLQuery.

Copy Code

    FixTicket.CommandText := 'DELETE FROM TrafficViolations WHERE (TicketID = 1099)';
    FixTicket.ExecSQL;

Copy Code

    FixTicket->CommandText = "DELETE FROM TrafficViolations WHERE (TicketID = 1099)";
    FixTicket->ExecSQL();

The ExecProc method if the dataset is an instance of TSQLStoredProc.

Copy Code

    SQLStoredProc1.StoredProcName := 'MyCommandWithNoResults';
    SQLStoredProc1.ExecProc;

Copy Code

    SQLStoredProc1->StoredProcName = "MyCommandWithNoResults";
    SQLStoredProc1->ExecProc();

Copy Code

If you are executing the query or stored procedure multiple times, it is a good idea to set the Prepared property to True.

See Also

Specifying the Command to Execute

Creating and Modifying Server Metadata

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