RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TADOQuery.SQL Property

Contains the text of the SQL statement to execute for the ADO query.

Pascal
property SQL: TWideStrings;
C++
__property TWideStrings SQL;

Use SQL to provide the SQL statement that an ADO query component executes when its ExecSQL or Open method is called. 

The SQL statement provided to the SQL property may contain replaceable parameters, following standard ADO syntax conventions. Parameters are created and stored in the Parameters property. 

At design-time, edit the SQL statement using the property editor invoked by clicking the ellipsis button of the property in the Object Inspector. At runtime, use properties and methods of string list objects to clear the current contents, add new contents, or to modify existing contents.

with ADOQuery1 do begin
  with SQL do begin
    Clear;
    Add('SELECT EmpNo, LastName, FirstName, HireDate');
    Add('FROM Employee');
  end;
  Open;
end;

 

ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT EmpNo, LastName, FirstName, HireDate");
ADOQuery1->SQL->Add("FROM Employee");
ADOQuery1->Open();

Note: The library does not evaluate the SQL sent to the database via a TADOQuery component. The SQL used must be valid for the particular database type accessed via ADO. Any error messages passed back to the application will have originated at the ADO or database level, and so will have error codes and messages specific to those systems.
 

Parameters 

Prepared 

ExecSQL 

ParamCheck 

Open 

Active

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