[SOLVED] Update DBGrid row lazarus / 16-Databases ---------------------------------------------------------------------- pcurtis · 2021-03-08 07:04 Hi All, is it possible to update / refresh / reload a single row / record in a DBGrid without refreshing the entire dataset? Thanks in advance. ---------------------------------------------------------------------- egsuh · 2021-03-09 01:31 If you open separate query, and replace the row of dataset which is showing on the DBgrid, then it will be possible. ---------------------------------------------------------------------- pcurtis · 2021-03-09 05:44 Thanks. Any code? ---------------------------------------------------------------------- egsuh · 2021-03-09 06:14 You should have followings, and they should be hooked as follow to display the content of qr1 on DBGrid. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     qr1, qr2: TSQLQuery;    DBGrid: TDBGrid;     DataSource: TDataSource;      DBGrid.DataSource= DataSource    DataSource.DataSet=qr1     qr1.SQL.Text := 'select pk, ... from table1 where ....'; Then you want to retrieve the record of current pk in qr2. That will look like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var    field: TField;begin    qr2.SQL.Text:= 'select   .. from table1 where pk = ' + qr1.FieldByName('pk').AsString;     qr2.Open;      qr1.Edit;   for field in qr2.Fields do          qr1.FieldByName(field.FieldName).AsString := field.AsString;     qr1.Post;end; This should work theoretically, but not sure. I haven't tested whether TSQLQuery can be edited and posted ---------------------------------------------------------------------- pcurtis · 2021-03-09 06:22 Thanks, i'll have a look. BTW I use zeos. ---------------------------------------------------------------------- EgonHugeist · 2021-03-09 17:44 Zeos8 allows you to use methode RefreshCurrentRow by default. The method will fail if you use a "complex query" i.e joined columns. To cirumvent the exception use the TZUpdateSQL component for the TZDataSet component, assign a RefreshSQL query and execute RefreshCurrentRow. ---------------------------------------------------------------------- pcurtis · 2021-03-10 01:23 Any sample of how to it? ---------------------------------------------------------------------- pcurtis · 2021-03-10 10:14 OK, I dont understand TZUpdateQuery so I did it this way   ZQuery1.DisableControls;   ZQuery1.Locate - record to change   ZQuery1.Edit;   ZQuery1.Fields.Fields[xxx].AsWhatever := new value;   ZQuery1.Post;   ZQuery1.EnableControls;