[solved] How to edit and save DBGrid record? lazarus / 16-Databases ---------------------------------------------------------------------- fpcoder · 2014-01-20 22:30 I have a SQLite table with countries in. It loads fine into a DBGrid with TQuery and TDataSource. But when I try to insert or edit a record, nothing can be typed in the cells and nothing is saved to database. Used Query.InsertSQL, but I still cannot type anything in the text cells: INSERT INTO countries(COUNTRY_ID, COUNTRY_NAME) VALUES(:COUNTRY_ID,:COUNTRY_NAME); Some working sample code would be appreciated. Attaching a small test app with a SQLite database.db3. Remember to change the database path in the dbconnection if you test it. Thanks in advance! ---------------------------------------------------------------------- kpeters58 · 2014-01-20 23:11 You have a few issues: The immediate problem being that you created your tables with TEXT columns which SQLDB treats as TMemofields (not editable in grid as they stand). Use VARCHAR instead and SQLDB will return TStringfields. Also: I do not see you doing any ApplyUpdates; search the forum - there must be dozens of posts related to that. Finally: Code: [Select]  //Simply prevents the hint about parameter Astate not used.   if gdSelected in AState then;                            The proper way to do this is to put a '{%H-}' in front of the parameter for which you want to suppress a hint (see: http://wiki.freepascal.org/IDE_directives ) ---------------------------------------------------------------------- fpcoder · 2014-01-21 23:01 Thanks for the help! I have changed from Text to VARCHAR(50) in SQLite database and it doesn't say just (memo) in the cells anymore. Then in the AfterPost event of the Query I added: Query.ApplyUpdates Transaction.CommitRetaining (Commit closes the dataset, but commitretaining keeps it active) ---------------------------------------------------------------------- kpeters58 · 2014-01-22 04:53 That should do it.  BTW, there is no point (though it also doesn't hurt) to specify VARCHAR(