Params

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloQuery > TApolloQuery Properties >

Params

Declaration

 

property Params[ Index: Word ] TParams;

Description

Contains the parameters for a query’s SQL statement. Access Params at runtime to view and set parameter names, values, and data types dynamically (at design time use the collection editor for the Params propeprty to set parameter information). Params is a zero-based array of TParams parameter records. Index specifies the array element to access. (See the Delphi / C++Builder help for more info on the TParams class).

 

image\tip.gif An easier way to set and retrieve parameter values when the name of each parameter is known is to call ParamByName. ParamByName cannot, however, be used to change a parameter’s data type or name.

 

Parameters used in SELECT statements cannot be NULL, but they can be NULL for UPDATE and INSERT statements.

Delphi Example

The following code runs an insert query to add a record for Lichtenstein into the country table.

 

ApolloQuery1.SQL.Clear;

ApolloQuery1.SQL.Add('INSERT INTO COUNTRY (NAME, CAPITAL, POPULATION)');

ApolloQuery1.SQL.Add('VALUES (:Name, :Capital, :Population)');

ApolloQuery1.Params[0].AsString := 'Lichtenstein';

ApolloQuery1.Params[1].AsString := 'Vaduz';

ApolloQuery1.Params[2].AsInteger := 420000;

ApolloQuery1.ExecSQL;

C++Builder Example

The following code runs an insert query to add a record for Liechtenstein into the country table.

 

ApolloQuery1->SQL->Clear();

ApolloQuery1->SQL->Add("INSERT INTO COUNTRY (NAME, CAPITAL, POPULATION)");

ApolloQuery1->SQL->Add("VALUES (:Name, :Capital, :Population)");

ApolloQuery1->Params->Items[0]->AsString = "Liechtenstein";

ApolloQuery1->Params->Items[1]->AsString = "Vaduz";

ApolloQuery1->Params->Items[2]->AsInteger = 420000;

ApolloQuery1->ExecSQL();