Recent

Author Topic: Update individual row in datagrid  (Read 749 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Update individual row in datagrid
« on: January 21, 2021, 12:38:08 pm »
Hi All,

I am using sqlite with zeos.

My question is "How can I show changes to a row in a DBGrid without refreshing the whole dataset?"

Test app attached.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

paweld

  • Hero Member
  • *****
  • Posts: 966
Re: Update individual row in datagrid
« Reply #1 on: January 21, 2021, 08:45:39 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   iTEMP : integer;
  4. begin
  5.   if ZQuery1.IsEmpty then
  6.   exit;
  7.   iTEMP := Random(10);
  8.   ZQuery1.Edit;
  9.   ZQuery1.FieldByName('fnCOUNT').AsInteger := iTEMP;
  10.   ZQuery1.ApplyUpdates;
  11.   Button2.Caption := iTEMP.ToString;
  12. end;      

if you use only one table in query you can do it this way, but if you use several tables (e.g. via JOIN) then you have to use the ZUpadateSQL component
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018