1 (edited by FMR 2024-12-21 00:03:25)

Topic: How to Update DB from EditBox ?

Hello

Can any one show me where is the wrong in this code ? I need update the database from editbox data directly.

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
SQLExecute('UPDATE Table_Name SET Field_Name = '+Form1.Edit1.Text+' where id = '+IntToStr(Form1.TableGrid1.dbItemID));
Form1.TableGrid1.dbUpdate;
end;
Life is like a school;
One can learn and graduate or stay behind.

Re: How to Update DB from EditBox ?

Hi FMR,
Try it like this

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
  SQLExecute('UPDATE table SET field = "'+Form1.Edit1.Text+'" where id = "'+Form1.TableGrid1.sqlvalue+'"');
  Form1.TableGrid1.dbUpdate;
  Form1.Edit1.clear;
end;

Regards,
Derek.

Re: How to Update DB from EditBox ?

Derek.

Thanks, This now it's work perfectly

Life is like a school;
One can learn and graduate or stay behind.