The error is correct, but not the only error in your code. Change your code to
ADOQuery1.Parameters.ParamByName('@nom_util').Value := 'John Smith';
(the =
may just have been a typo, in Delphi's Pascal, the assignment operator is :=
, not =
.)
Ado parameters do not have an AsString
or AsValue
property. They are of type TParameter
, defined in AdoDB.Pas as
TParameter = class(TCollectionItem)
[...]
public
procedure Assign(Source: TPersistent); override;
procedure AppendChunk(Val: OleVariant);
procedure LoadFromFile(const FileName: string; DataType: TDataType);
procedure LoadFromStream(Stream: TStream; DataType: TDataType);
property ParameterObject: _Parameter read GetParameter;
property Parameters: TParameters read GetParameters;
property Properties: Properties read GetProperties;
published
property Name: WideString read GetName write SetName;
property Attributes: TParameterAttributes read GetAttributes write SetAttributes default [];
property DataType: TDataType read GetDataType write SetDataType default ftUnknown;
property Direction: TParameterDirection read GetParameterDirection write SetParameterDirection default pdInput;
property NumericScale: Byte read GetNumericScale write SetNumericScale default 0;
property Precision: Byte read GetPrecision write SetPrecision default 0;
property Size: Integer read GetSize write SetSize default 0;
property Value: Variant read GetValue write SetValue;
end;
Update I can tell from your comments that there is a certain amount of confusion. Perhaps this will help:
Suppose you have a Names table with an AName field and you want to find the row with the value
'Me' in the AName field.
The following code will do it:
AdoConnection1.Connected := True;
AdoQuery1.SQL.Text := 'select * from [Names] where AName = :AName';
AdoQuery1.Parameters.ParamByName('AName').Value := 'Me';
AdoQuery1.Open;
In the SQL.Text, :AName
is simply a placeholder for the parameter in the query.
The convention is that the text following the ':' is the name of the table column,
but it doesn't have to be, any valid Sql name will do, as in
AdoQuery1.SQL.Text := 'select * from [Names] where AName = :Something';
AdoQuery1.Parameters.ParamByName('Something').Value := 'Me';