Background
I have a working program to migrate MS Access database data to SQLite that has been ok for many months. A change was required to the SQLite data structure so I re-ran the "working" program but had problems with the following line but only on the second call to the function.
iRes:= dbQuery.FieldByName(strKey).AsString; //This failing for ColUnits
The SQL for the query was correct, copied from ShowMessage and run in the database browser, producing the expected output. After several hours of frustrated head scratching I hard coded a fix to jump over this troublesome piece of code.
Next I started getting
Operation cannot be performed on active dataset. Searching the forum I found this from BigChimp, 2012
QDetail.Close;
QDetail.SQL.Text:=Format(AdresLatest, [inttostr(NameID)]);
QDetail.Open;
and this from Knipfty on the same post
I've found that anytime you change the SQL Text property, the dataset needs to be closed. The IDE does this automatically and forces you to set active to true to see the result. It doesn't surprise me that you need to do this programically as well.
Putting .close in before each of my SQL.Text statements fixed all my problems. It seems to me that there has been some kind of change within the IDE and possible the version of FPC I was using (maybe Laz-FPC 3.3.1-3.9.9 not certain of the version) and the Laz-FPC 3.4-3.2.2 I use currently.
Are internal changes such as these documented and if so where?
Huge thanks to both BigChimp and Knipfty