Executing the Command

From RAD Studio
Jump to: navigation, search

Go Up to Executing Commands That Do Not Return Records


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.

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

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

SQLStoredProc1.StoredProcName := 'MyCommandWithNoResults';
SQLStoredProc1.ExecProc;
SQLStoredProc1->StoredProcName = "MyCommandWithNoResults";
SQLStoredProc1->ExecProc();



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