Hello, i need help with this SQL.An error is occurring that says: Parameter "user" not found.Code: Pascal [Select][+][-]procedure TForm1.btnExecutar2Click(Sender: TObject);begin SQLQuery2.Close; SQLQuery2.SQL.Clear; SQLQuery2.UpdateSQL.Add('UPDATE access _register SET password= :password WHERE user = :user'); SQLQuery2.Params.ParamByName('user').AsString := 'jr'; SQLQuery2.Params.ParamByName('password').AsString:= '12345'; try //SQLQuery2.Active:=True; //SQLQuery2.Open; //SQLQuery2.Prepare; SQLQuery2.ExecSQL; SQLTransaction2.Commit; except on E: Exception do begin ShowMessage('Error: ' + E.Message ); end; end;end;
You must set the params before UpdateSQL.Add
Code: Pascal [Select][+][-]begin SQLQuery2.Close; SQLQuery2.SQL.Clear; SQLQuery2.Params.ParamByName('user').AsString := 'jr'; SQLQuery2.Params.ParamByName('password').AsString:= '12345'; SQLQuery2.UpdateSQL.Add('UPDATE access _register SET password= :password WHERE user = :user'); try
He clears the SQL-Prop of his Query2, but then Adds to the UpdateSQL-Property......Why not justQuery2.SQL.Clear;Query2.SQL.Text:='UPDATE blablablablabnl....';Query2.Params...blablabla;Query2.ExecSQL;