RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TSQLQuery.ExecSQL Method

Executes a query that does not return a set of records.

Pascal
function ExecSQL(ExecDirect: Boolean = False): Integer; override;
C++
virtual __fastcall int ExecSQL(Boolean ExecDirect = False);

Call ExecSQL to execute an SQL command that does not return a set of records. This command is a query other than a SELECT query, such as an INSERT, UPDATE, DELETE, or CREATE TABLE query. 

ExecDirect indicates that the query does not need to be prepared before it is executed. This parameter can be set to true if the query does not include any parameters. When ExecDirect is false, the query will be prepared before it is executed. Even when ExecDirect is false, you can avoid preparing the query every time ExecSQL is called by setting the Prepared property to true before calling ExecSQL the first time. 

ExecSQL returns the number of rows affected by the executed command. This becomes the value of the RowsAffected property.

Note: Do not use ExecSQL for commands such as SELECT queries that return data. When the command returns data, use the Open method or set the Active property to true.
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!