Class TDAOQuery (unit DAOQuery)

Inherits from

TDAODataset

TDAOQuery encapsulates a dataset with a result set that is based on an SQL statement.

Functions

procedure Execute;


function MacroByName(const Value: string): TParam;


function ParamByName(const Value: string): TParam;


Properties

property FilterText :


property MacroChar : Char


property Macros : TParams


property OpenType : TDAOQueryOpenType


property Params : TParams


property SortText :


property SQL : TStrings


property MacroCount : Integer


property ParamCount : Integer


property RecordsAffected : Integer


Functions

procedure Execute;

Executes the SQL statement.
Call Execute to execute the INSERT, UPDATE, or DELETE statement with or without parameters.


function MacroByName(const Value: string): TParam;

To set macros at run time by name.
Example:
DAOQuery1.MacroByName('Order').AsString := 'Customer_Id';


function ParamByName(const Value: string): TParam;

To set input parameters at run time by name.
Example:
DAOQuery1.ParamByName('Customer_Name').AsString := Edit1.Text;

Properties

property FilterText :

The property FilterText allows to apply the filter to Recordset.

Note

The filters cannot be applied to TDAOTable with OpenType = db_Open_Table.


property MacroChar : Char

The property MacroChar defines symbol, which is used for macro definition.

Note

Do not use ':' symbol, as it is used for definition of parameters of query.


property Macros : TParams

Contains the macroses for a query’s SQL statement.
It is convinient to use macroses, when it is necessary to modify query at runtime.

For example, you can use macroses to change order clause of sql statement:

DAOQuery1.SQL.Text := 'SELECT * FROM Customers ORDER BY %Order';
DAOQuery1.MacroByName('Order').AsString := 'Customer_Id';


property OpenType : TDAOQueryOpenType

OpenType defines type of returned result set.

OpenType is set from the following values:
db_OpenDynaset Opening of Recordset such as a dynamic set of records.
db_OpenSnapshot Opening of Recordset such as a static set of records.
Look at DAO 3.5 help for additional details.


property Params : TParams

Contains the parameters for a query’s SQL statement.
Look at TQuery's help for additional details.


property SortText :

The property SortText sets sort order to Recordset.

Note

Sort order cannot be applied to TDAOTable with OpenType = db_Open_Table.


property SQL : TStrings

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


property MacroCount : Integer

Indicates the current number of macroses for the query.


property ParamCount : Integer

Indicates the current number of query's parameters.


property RecordsAffected : Integer

Returns number of records, which were used by the last call of a method Execute.