RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TParameters.ParamByName Method

Locates the parameter with a given name.

Pascal
function ParamByName(const Value: WideString): TParameter;
C++
__fastcall TParameter ParamByName(const BSTR Value);

Use ParamByName method to find a parameter with the name specified in Value. If a match is found, ParamByName returns a reference to the corresponding TParameter object. Otherwise, the TParameter reference is nil (Delphi) or NULL (C++) and an exception is raised. Use this method rather than a direct reference to the Items property to avoid depending on the order of the entries.

ADOQuery1.Parameters.ParamByName('Verb').Value := 'propitiate';
ADOQuery1.Open;

 

ADOQuery1->Parameters->ParamByName("Verb")->Value = "propitiate";
ADOQuery1->Open();

To locate a parameter by name without raising an exception if the parameter is not found, use the FindParam method. 

To locate more than one parameter at a time, by name, use the GetParamList method instead. To get only the value of a named parameter, use the ParamValues property.

Note: ParamByName operates with the name of a parameter as it appears in an SQL statement or stored procedure, not the Name property of a TParameter object. The two ways of referring to a parameter should not be confused.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!