TFDQuery doesn't open by params value if SQL doesn't specify the param condition

234 Views Asked by At

I have the following code for TFDQuery:

FDQuery1.SQL.Text := 'SELECT * FROM Employees';
FDQuery1.Params.CreateParam(ftString, 'Name', ptInput).Value := 'Test';
FDQuery1.Open;
showmessage(FDQuery1.RecordCount.ToString);

If let said Employees table got 10 records, The FDQuery1.RecordCount will return 10 instead of 1. But if i change the above code with this, it will return 1

FDQuery1.SQL.Text := 'SELECT * FROM Employees WHERE Name=:Name';

Since i migrating DB Express to firedac, the previous TSQLDataSet allow me to specify SQL like this and it will return recordcount = 1 if param is specified

SELECT * FROM Employees

May i know anyway to allow it return proper result by param value even sql didn't specify the param condition. Thanks

0

There are 0 best solutions below