RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TSQLConnection.Execute Method

Executes an SQL command on the server.

Pascal
function Execute(const SQL: WideString; Params: TParams; ResultSet: TPSResult = nil): Integer;
C++
__fastcall int Execute(const BSTR SQL, TParams Params, TPSResult ResultSet = nil);

Call Execute to execute a single command on the server without the overhead of using an SQL dataset. Execute is especially useful for statements that do not return a result set such as data definition language (DDL) statements. 

SQL is the command to execute. 

Params is a TParams object that contains any parameters used by the SQL statement. Parameter binding is by index only (not by name), so the order of parameters is important and the order of the TParam objects in Params corresponds to the order of the parameters in the SQL statement. Use properties and methods of TParams to create a TParams object, add TParam objects for each parameter, and assign parameter properties such as datatype and value. If the SQL statement does not include any parameters, pass a nil (Delphi) or NULL (C++) value for Params

ResultSet is a pointer to a variable of type TCustomSQLDataSet*. If the SQL statement returns a cursor, Execute creates a new TCustomSQLDataSet instance and populates it with the result set. The new TCustomSQLDataSet reference is returned as the value to which ResultSet points. If the SQL statement does not return a result set, pass a nil (Delphi) or NULL (C++) value for ResultSet. TPSResult is is set to Pointer for native code and TObject for managed code. 

Execute returns the number of records affected by executing the SQL statement.

Tip: If the SQL statement does not include any parameters, you can use the ExecuteDirect method instead.
 

 

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