Hello
I am getting an error when passing parameters to a TSQLQuery object.
The following code works without parameters:
//--------- begin code
begin
Form2.SQLQuery2.SQL.Clear;
Form2.SQLQuery2.SQL.Add('update USR_CUST_FIN_CHRG');
Form2.SQLQuery2.SQL.Add('set AMT_PAST_DUE = 110');
Form2.SQLQuery2.SQL.Add('where CUST_NO = ' + '''1435''');
Form2.SQLQuery2.ExecSQL;
Form2.SQLTransaction2.Commit;
end
//--------- end code
I change the code to work with parameters such as below:
//--------- begin code
var
v_cust_no: string[15];
v_amt_past_due: real;
begin
v_cust_no:= '1435';
v_amt_past_due:= 110;
Form2.SQLQuery2.SQL.Clear;
Form2.SQLQuery2.SQL.Add('update USR_CUST_FIN_CHRG');
Form2.SQLQuery2.SQL.Add('set AMT_PAST_DUE = :amt_past_due');
Form2.SQLQuery2.SQL.Add('where CUST_NO = :cust_no');
Form2.SQLQuery2.ParseSQL := true;
Form2.SQLQuery2.Params.ParamByName('amt_past_due').AsFloat := v_amt_past_due;
Form2.SQLQuery2.Params.ParamByName('cust_no').AsString := v_cust_no;
Form2.SQLQuery2.ExecSQL;
Form2.SQLTransaction2.Commit;
end
//--------- end code
When I run the code, I get the following error:
Project project1 raised an exception class 'EDatabaseError' with message:
Parameter "amt_past_due" not found
At address 54ADAC
What am I doing wrong?
Regards,