check update with rowsaffected always gives -1 lazarus / 16-Databases ---------------------------------------------------------------------- mangakissa · 2019-12-14 11:49 With this peace of code I save a record by inserting / updating: 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 TDBWorld.SaveToDatabase(const aNewRecord: boolean);var Country  : TCountry;    obJID    : integer;    MyQuery  : TStrings;begin  Myquery := TStringlist.create;  try    if aNewRecord then    begin      MyQuery.AddText('INSERT INTO countries (name, capital, population, continent_id)');      MyQuery.AddText('VALUES (:name, :capital, :population, :continent_id)');      if fWorld.Countrylist.Count = 0 then        objID := 0      else        objID := fWorld.Countrylist.Count - 1;    end else    begin      MyQuery.AddText('UPDATE countries SET');      MyQuery.AddText('name = :name, capital = :capital,');      MyQuery.AddText('population = :population, continent_id = :continent_id');      MyQuery.AddText('WHERE id = :id');      objID := fWorld.fID;    end;  Country := fWorld.Countrylist[objID];    fSQLQuery.SQL.Text := MyQuery.Text;    fSQLQuery.Params[0].AsString := Country.name;    fSQLQuery.Params[1].AsString := Country.capital;    fSQLQuery.Params[2].AsString := Country.population;    fSQLQuery.Params[3].AsInteger := Country.continent_id;    if not aNewRecord then      fSQLQuery.Params[4].AsInteger := Country.id;    fSQLQuery.ExecSQL;    if DMConnection.SQLConnector1.ConnectorType <> 'SQLite3' then      fSQLTransaction.Commit    else      dmConnection.SQLTransaction1.Commit;    showmessage(inttostr(fSQLQuery.RowsAffected));    if aNewRecord then    Country.id := GetLastID;  finally    MyQuery.free;  end;end; fSQLQuery.RowsAffected gives -1 when updating the record. I can see in the database (sqlite) the record is updated. How can I check in Lazarus if this is true. I'm using Lazarus 2.04 64b /FPC 3.04 on Windows 10 ---------------------------------------------------------------------- sash · 2019-12-14 13:11 Probably you should read RowsAffected before ending a transaction (Commit). ---------------------------------------------------------------------- mangakissa · 2019-12-16 07:37 Thanks. It works.