Recent

Author Topic: SQLite:Unexpected Column Not Found After Upgrading To Lazarus 3.4  (Read 652 times)

Wilko500

  • Jr. Member
  • **
  • Posts: 91
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.
Code: Pascal  [Select][+][-]
  1.   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

Quote
    QDetail.Close;
      QDetail.SQL.Text:=Format(AdresLatest, [inttostr(NameID)]);
      QDetail.Open;

and this from Knipfty on the same post

Quote
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




MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.3.1 Lazarus 3.99
FPC 3.2.2 Lazarus 3.4

Khrys

  • Jr. Member
  • **
  • Posts: 81
Re: SQLite:Unexpected Column Not Found After Upgrading To Lazarus 3.4
« Reply #1 on: July 04, 2024, 06:49:08 am »
Are internal changes such as these documented and if so where?

You can always look through the commit history of the compiler source tree on GitLab; or more specifically, that of the  fcl-db  package which contains the database units.

af0815

  • Hero Member
  • *****
  • Posts: 1356
Re: SQLite:Unexpected Column Not Found After Upgrading To Lazarus 3.4
« Reply #2 on: July 04, 2024, 08:38:32 am »
Putting .close in before each of my SQL.Text statements fixed all my problems. 
To close the Query before i change a statement (or add) was normal for ages for me (exactly since my Delphi 7 times). Maybe it was accepted by accident sometimes, so it was no internal change - more a bugfix :-)
regards
Andreas

 

TinyPortal © 2005-2018