TDBGrid is not updating record lazarus / 16-Databases ---------------------------------------------------------------------- vfclists · 2009-03-27 09:08 I am just trying out Lazarus and its Database components, and I have add all the necessary components to link to the database and the records are showing in the grid. However all though new records and updated records show in the grid, they are not updated into the database. Are there some additional stuff to do - I thought they would work like in Delphi? Are there some samples, showing how it works? Is it necessary to modify the Insert, Update, and DeleteSQL properties, and make some changes in the Transaction component to get it work. I would like some links to examples please. Thx Frank ---------------------------------------------------------------------- Loesje · 2009-03-27 13:00 You provided way too less information. "all the necessary components" We'll see about that. But I'm in a goo mood so I'll guess around. First guess: You used the TSQLQuery from Sqldb. Second guess: you used a database which uses transactions (Firebird, PostgreSQL) and forgot to commit the transaction. (TSQLTransaction.Commit) So the changes thrown away when your application quits. Third guess: You forgot to call TSQLQuery.ApplyUpdates to store the changes in the database at all. ---------------------------------------------------------------------- vfclists · 2009-03-31 08:35 Quote from: Loesje on March 27, 2009, 02:00:34 pmYou provided way too less information. "all the necessary components" We'll see about that. But I'm in a goo mood so I'll guess around. First guess: You used the TSQLQuery from Sqldb. Second guess: you used a database which uses transactions (Firebird, PostgreSQL) and forgot to commit the transaction. (TSQLTransaction.Commit) So the changes thrown away when your application quits. Third guess: You forgot to call TSQLQuery.ApplyUpdates to store the changes in the database at all. 1. All the necessary components are there, Connection, Query and Transaction components, DataSource and Grid are all present and linked up. 2. I am connecting to a MySQL database 3. The UpdateSQL, InsertSQL and DeleteSQL settings are not set, which I believe is not necessary unless is is a join query. This is a straight select query from a table with a primary key. 4. If I am to use ApplyUpdates, which event should they be attached to. I think docs are what I need, but the wiki is rather skimpy. ---------------------------------------------------------------------- Loesje · 2009-03-31 10:43 There are no connection, query and transaction components in Lazarus. So I still don't know which components you used. (There is, for example a TSQLQuery component. Did you use that?) And you can call applyupdates at any moment you want. One idea would be to add a 'save' button, for example. Or when you close the window. Or when you scroll to another record. But that's up to you to decide ---------------------------------------------------------------------- vfclists · 2009-03-31 12:12 I got it working after adding code to the InsertSQL, DeleteSQL and UpdateSQL properties, and by calling ApplyUpdates in the AfterPost event. Quote from: Loesje on March 31, 2009, 12:43:41 pmThere are no connection, query and transaction components in Lazarus. So I still don't know which components you used. (There is, for example a TSQLQuery component. Did you use that?) And you can call applyupdates at any moment you want. One idea would be to add a 'save' button, for example. Or when you close the window. Or when you scroll to another record. But that's up to you to decide