SqlQuery update status lazarus / 16-Databases ---------------------------------------------------------------------- Hansvb · 2022-06-20 13:30 Hi, The user can make changes in a table via a DbGrid. Now I only want to save if there are actually mutations. How can you check for that? I thought of doing this with SqlQuery.UpdateStataus. But this only seems to be activated if you first go to a following line in the DbGrid. I want to see the UpdateStatus change as soon as I exit the cell. Is that possible? 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 procedure TFrm_Main.DBGridMain1ColExit(Sender: TObject);begin  case DataModuleMain.SQLQuery1.UpdateStatus of   usUnmodified :  Button2.Caption:='usUnmodified';   usModified :  Button2.Caption:='usModified';   usInserted :  Button2.Caption:='usInserted';   usDeleted :  Button2.Caption:='usDeleted';  end;end; ---------------------------------------------------------------------- Zvoni · 2022-06-20 13:56 Why not use OnSelection-Event? You need variables for oldValue, oldRow and oldCol where you save Row and Col when selecting a cell OnSelection ships Col and Row of the newly selected Cell Compare newValue to oldValue of Cell at "old" Col/Row, if "dirty" then update. Set oldCol/oldRow to current Col/Row, oldValue to current value ---------------------------------------------------------------------- Hansvb · 2022-06-20 17:47 Found something which i can use: Datasource.state. if a cell in DbGrid is changed the datasource state changes. To see what happens when a cell changes: 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 procedure TDataModuleMain.DataSource1StateChange(Sender: TObject);begin  case DataSource1.State of  dsInactive:    begin      ShowMessage('dsInactive');    end;  dsBrowse:    begin      ShowMessage('dsBrowse');    end;  dsEdit:    begin      ShowMessage('dsEdit');    end;  dsInsert:    begin      ShowMessage('dsInsert');    end;  dsCalcFields:    begin      ShowMessage('dsCalcFields');    end;  dsCurValue:    begin      ShowMessage('dsCurValue');    end;  dsNewValue:    begin      ShowMessage('dsNewValue');    end;  dsOldValue:    begin      ShowMessage('dsOldValue');    end;  dsFilter:    begin      ShowMessage('dsFilter');    end;  end;end;