[SOLVED] Deactivate active DataSet? lazarus / 16-Databases ---------------------------------------------------------------------- Elmug · 2012-06-28 22:29 Hi everyone, This is on working with SQLite3, SQLite3Connecton1, a one-table learning project. I have a button called ApplySELECTquery which sends an editable SELECT * etc query and data shows correctly in the Grid. I gather, at that point I have the DataSet active, that matches the query sent. When I edit the query, though, and push the said button again, the error  message is can not do it on an active dataset. So, I need to add code to the said button to de-activate, or destroy (or whatever), the DataSet, prior to sending a new query. I tried quite a few things, and none have yet worked. Also, perhaps I can get something to work, but I rather ASK which is the recommended way to do what I am after. I gather that when done correctly, the memory and resources of the dataset should be released, plus do whatever else needs to happen, for the right way to do this. The Grid would then show the new dataset, too, of course. Thanks for any help afforded. ---------------------------------------------------------------------- paweld · 2012-06-28 22:38 Code: [Select]SQLQuery1.Active:=False; SQLQuery1.SQL.Text:='select * from another_table'; SQLQuery1.Active:=True; ---------------------------------------------------------------------- Elmug · 2012-06-28 23:49 Quote from: paweld on June 29, 2012, 12:38:02 amCode: [Select]SQLQuery1.Active:=False; SQLQuery1.SQL.Text:='select * from another_table'; SQLQuery1.Active:=True; Hi Paweld, and thanks for helping! Actually, what you state is pretty much exactly what I was trying, but my problem was that I am setting the SQLQuery1.SQL by means of onEditDone of the memo box where and when the query is typed. Assigning value to the SQL property is rejected at run time, unless the  SQLQuery1.Active:=False. I did not know that. So, the problem was that I was doing the SQLQuery1.Active:=False in the code for the button ApplySelectQuery, and I actually need (and now have) that line in the onEditingDone of the query. The first time the program runs, it would work, though. But not subsequently, since the app starts with the Active := False. By the way, your post really should say SQL where it says Text : SQLQuery1.SQL.Text:='select * from another_table'; Also, a constant string can not be passed to the SQL property, since it is type TStringList. I do have more question on this issue, though: By closing the active DataSet as above, do the buffers, memory, and resources used by the active DataSet get released? Thanks a lot. Your post helped me solve the issue. ---------------------------------------------------------------------- Knipfty · 2012-07-17 15:13 Hi Elmug, Look at this link to find the definitions of properties and methods: http://www.freepascal.org/docs-html/fcl/db/tdataset.active.html Basically, setting active to true/false is the same as opening/closing.  MY guess is that once closed, the buffer is cleared. ---------------------------------------------------------------------- Elmug · 2012-07-17 20:55 Quote from: Knipfty on July 17, 2012, 05:13:05 pmHi Elmug, Look at this link to find the definitions of properties and methods: http://www.freepascal.org/docs-html/fcl/db/tdataset.active.html Basically, setting active to true/false is the same as opening/closing.  MY guess is that once closed, the buffer is cleared. Thanks, Knipfty. I believe that is so.