TSQLQuery re-read database lazarus / 16-Databases ---------------------------------------------------------------------- Ferke · 2017-09-26 16:45 Hi! I use Lazarus with Firebird for a project. I use the visual component TSQLQuery for reading the database. My problem is that these components buffer the table, and if another programm updates a record in the table, I will not see it in my programm. How can I force the TSQLQuery to re-read the table from the database and not to provide data from its buffer? Refresh is not working. Thanks! ---------------------------------------------------------------------- GAN · 2017-09-26 19:29 I think you can force it closing and opening the query. If that's don't work, try closing a opening the connection too. ---------------------------------------------------------------------- taazz · 2017-09-26 20:34 Quote from: Ferke on September 26, 2017, 06:45:08 pmHi! I use Lazarus with Firebird for a project. I use the visual component TSQLQuery for reading the database. My problem is that these components buffer the table, and if another programm updates a record in the table, I will not see it in my programm. How can I force the TSQLQuery to re-read the table from the database and not to provide data from its buffer? requery the data ee sqlquery1.close; sqlquery1.open. Quote from: Ferke on September 26, 2017, 06:45:08 pmRefresh is not working. are you sure? Do this little test. Open your application twice open the same data on both instances locate the same record on both, change the data on one and press refresh on the other does the second show the new data or the old data of the record? ---------------------------------------------------------------------- mangakissa · 2017-09-27 06:18 If the updated record is not comitted, a refresh or close / open will not work. ---------------------------------------------------------------------- Ferke · 2017-09-27 11:55 First of all, thanks for your replies. I will try to reply to all of you. Close and open will not work. It works if I update the record in the same programm (let's say this is programm A), but if I use an external program (programm B), it will not work. Also the refresh not. They have been tested. The record is updated in the database by the programm B, that is sure, if I check it with the database explorer, or simply restart programm A, the updated record will appear. Closing the database connection is a working solution, but this programm use temporary tables and has intensive trafic to the database, so the connection cannot be closed. ---------------------------------------------------------------------- Ferke · 2017-09-27 17:15 Quote from: mangakissa on September 27, 2017, 08:18:59 amIf the updated record is not comitted, a refresh or close / open will not work. Okay, it did the work but I needed not at the update only. If I add to the code 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 SQLTransaction.Commit;, and the close and open, it will re-fetch the updated records from the database. I don't really understand, since it is a select statement, but it works. Thanks for the help. ---------------------------------------------------------------------- taazz · 2017-09-27 17:21 Quote from: Ferke on September 27, 2017, 07:15:13 pmQuote from: mangakissa on September 27, 2017, 08:18:59 amIf the updated record is not comitted, a refresh or close / open will not work. Okay, it did the work but I needed not at the update only. If I add to the code 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 SQLTransaction.Commit;, and the close and open, it will re-fetch the updated records from the database. I don't really understand, since it is a select statement, but it works. Thanks for the help. do you by any chance activate the transaction manually? ---------------------------------------------------------------------- Ferke · 2017-09-27 17:51 No. Why? ---------------------------------------------------------------------- taazz · 2017-09-27 17:57 Quote from: Ferke on September 27, 2017, 07:51:52 pmNo. Why?  as far as I remember TSQLQuery auto manages its transactions unless it was already open when the query opened it self. It might be a case of memory failure on my part I'll have to double check it. ---------------------------------------------------------------------- Ferke · 2017-09-27 18:14 Hmmm, please give a short feedback if you have restored your memory. It could be a useful information for me. There is a side effect now, I have to start manually the transaction beacause other methods cannot acces the DB now. This is a program that accepts requests on a TCP socket, so there are many transactions in the background. Another interesting thing: CommitRetaining does not help in my case. I have to close the transactions and reopen them to re-fectch the fresh data.