TDBNavigator can not save new records back to sqlite3 db under windows lazarus / 16-Databases ---------------------------------------------------------------------- Goodman H__ · 2010-05-22 04:58 Greetings to everybody! Just found that.Using TDBNavigator to insert a new record by click button(+),and then save it by click save button(V) does not really save the new record when I check back the sqlite database. Was I missing something?Thank you all for your reply to my silly questions since I am a newbie to FP and Lazarus. Regards, Sam ---------------------------------------------------------------------- stonefull · 2010-05-22 09:54 I guess you're using SQLdb. After saving you should run the following commands: SQLQuery.ApplyUpdates; SQLTransaction.CommitRetaining; ---------------------------------------------------------------------- Goodman H__ · 2010-05-22 10:20 Quote from: stonefull on May 22, 2010, 11:54:18 amI guess you're using SQLdb. After saving you should run the following commands: SQLQuery.ApplyUpdates; SQLTransaction.CommitRetaining; Thank you.Yes,I am using Sqlite3. But may I ask where do I code the above command? Thanks again. Regards, Sam ---------------------------------------------------------------------- AlZuur · 2010-05-22 13:32 Of course there are several possibilities. And of course it depends. If you want to save when closing the form, put it in the close button's OnClick event. You can then make a cancel button that closes the form without saving (or SQLQuery.CancelUpdates to throw the updates away). Otherwise, if you want to (ab)use the Post button to save the records, TDBNavigator has an OnClick event that has a Button parameter. In the event procedure you can use:   If Button = nbPost then     SQLQuery.ApplyUpdates; ---------------------------------------------------------------------- Goodman H__ · 2010-05-23 01:29 Quote from: AlZuur on May 22, 2010, 03:32:46 pm Otherwise, if you want to (ab)use the Post button to save the records, TDBNavigator has an OnClick event that has a Button parameter. In the event procedure you can use:   If Button = nbPost then     SQLQuery.ApplyUpdates; This is exactly what I want.Appreciated! EDIT: I test both in Lazarus 0.9.29+FP2.4.0 and Lazarus0.9.29+FP2.4.1 daily snapshot.The result is as below: For FPC2.4.1 snapshot,Lazarus complained that it does not found sqlite3_bla_bla in the sqlite3.dll For FPC2.4.0,the program compiles and runs when I test both method your mentioned the above.Please note I tested these two method separately,no both codes in the same application. 1.In TDBNavigator,result is that new record still does not save to the db; 2. In a button with below code: Code: [Select] SQLQuery.ApplyUpdates; SQLTransaction.CommitRetaining; When trying to insert a new record in the DBGrid and then press the said button,the applicaton throw an exception that db is locked. Regards, Sam ---------------------------------------------------------------------- Goodman H__ · 2010-05-23 23:00 Quote from: Goodman H__ on May 23, 2010, 03:29:27 amQuote from: AlZuur on May 22, 2010, 03:32:46 pm Otherwise, if you want to (ab)use the Post button to save the records, TDBNavigator has an OnClick event that has a Button parameter. In the event procedure you can use:   If Button = nbPost then     SQLQuery.ApplyUpdates; This is exactly what I want.Appreciated! EDIT: I test both in Lazarus 0.9.29+FP2.4.0 and Lazarus0.9.29+FP2.4.1 daily snapshot.The result is as below: For FPC2.4.1 snapshot,Lazarus complained that it does not found sqlite3_bla_bla in the sqlite3.dll For FPC2.4.0,the program compiles and runs when I test both method your mentioned the above.Please note I tested these two method separately,no both codes in the same application. 1.In TDBNavigator,result is that new record still does not save to the db; 2. In a button with below code: Code: [Select] SQLQuery.ApplyUpdates; SQLTransaction.CommitRetaining; When trying to insert a new record in the DBGrid and then press the said button,the applicaton throw an exception that db is locked. Regards, Sam I also try to test under Ubuntu,when I set SQL string of SqlQuery control Code: [Select]select * from city; and then execute the sql command,Error message shows"no table city". but table city is exactly there and ready to use. ---------------------------------------------------------------------- stonefull · 2010-05-24 05:36 see this example that works on Ubuntu: http://sites.google.com/site/carlosctrl/documentos- 1/Clientes_SQLdb.zip?attredirects=0&d=1 ---------------------------------------------------------------------- Goodman H__ · 2010-05-24 07:36 Quote from: stonefull on May 24, 2010, 07:36:41 amsee this example that works on Ubuntu: http://sites.google.com/site/carlosctrl/documentos- 1/Clientes_SQLdb.zip?attredirects=0&d=1 Thank you.Pity I can not open the page.Maybe it's blocked in my rigion... ---------------------------------------------------------------------- stonefull · 2010-05-24 08:29 I can send it by e-mail, if you want. ---------------------------------------------------------------------- Goodman H__ · 2010-05-25 06:52 Quote from: stonefull on May 24, 2010, 10:29:21 amI can send it by e-mail, if you want. Yes,please.to samhu.samhu@gmail.com Appreciated!!! ---------------------------------------------------------------------- Goodman H__ · 2010-05-31 23:44 Hi, I have tested all the daily snapshot recently under my windows xp but the subjected problem still is there:new record can not write back to database whatever I do on whichever computer,my desktop,my laptop,my wife's laptop... Is there anybody else met the same problem b4? Thanks for the help. Regards, Sam