Hello, i need help with this SQL.Shouldn't "access _register" be only one word instead of two?
An error is occurring that says: Parameter "user" not found.
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.AddThis doesn't seem to be relevant.
But, an UPDATE command without a SELECT command might become an issue.
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 just
Query2.SQL.Clear;
Query2.SQL.Text:='UPDATE blablablablabnl....';
Query2.Params...blablabla;
Query2.ExecSQL;