Recent

Author Topic: [Solved!] DBLookupListBox shows (MEMO) in place of the data  (Read 1135 times)

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
[Solved!] DBLookupListBox shows (MEMO) in place of the data
« on: December 10, 2024, 10:51:08 am »
Hi all,

I have a DBLookupListBox connected to an SQLite database. I previously had an issue where all entries were appearing in the box as (MEMO) instead of displaying the string.  Someone on here suggested I cast the entries as CHAR. I've been using the following query for 2 years with no issues:

SELECT CAST(Issue AS CHAR) AS Issue, ID FROM MasterProtocol

Without me changing anything other than FPC/Lazarus version (and I presume Sqlite version as well), this has suddenly stopped working and is now displaying (MEMO) in place of the actual data again.  I have tried casting to VARCHAR and TEXT, have tried ensuring the field definition in the query is a String, both in the inspector and in code. Nothing works - I can't get this to display anything but (MEMO) in the DBLookupListBox. Very confusing and frustrating, I have several of these in my program so it's basically broken at the moment until I can figure this out.

Current SQlite version is 3.45.1
Oh and I doubt it's relevant but I did change from using Fedora to using Mint as well.

Any help is appreciated, thanks a lot for your time.
« Last Edit: December 11, 2024, 09:24:34 am by heebiejeebies »
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

Zvoni

  • Hero Member
  • *****
  • Posts: 2792
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #1 on: December 10, 2024, 10:57:23 am »
There were some changes in the sqlite3connection-class

Use OnGetText-Event
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #2 on: December 10, 2024, 11:14:42 am »
Thanks. I tried putting this in the OnGetText event of the field:

Code: Pascal  [Select][+][-]
  1.   Text := Sender.AsString;

Now everything is showing up as blank instead of (MEMO).
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #3 on: December 10, 2024, 11:21:21 am »
Hmm, I just noticed when I look at the relevant field in the query using the inspector, the BlobType is stuck on ftMemo? i.e. When I pick another option from the dropdown it stays as ftMemo. Don't know if that's relevant but I just noticed it.
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

Zvoni

  • Hero Member
  • *****
  • Posts: 2792
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #4 on: December 10, 2024, 12:26:03 pm »
Hmm, I just noticed when I look at the relevant field in the query using the inspector, the BlobType is stuck on ftMemo? i.e. When I pick another option from the dropdown it stays as ftMemo. Don't know if that's relevant but I just noticed it.
It is. Try it out if it works.
Since i don't use DB-Bound controls i'm not that much help
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #5 on: December 10, 2024, 08:12:05 pm »
Thanks. I don't know what you mean by try it out. There's nothing to try - it doesn't move from Memo. I've tried changing it in code and it still doesn't work.
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

Sieben

  • Sr. Member
  • ****
  • Posts: 372
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #6 on: December 10, 2024, 11:10:25 pm »
I suppose that field isn't the only Text in your database / application - do other fields you did cast in the way described in your first post work as expected?

There were some changes in the sqlite3connection-class

Do you happen to know what these changes are?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #7 on: December 11, 2024, 04:02:30 am »
I suppose that field isn't the only Text in your database / application - do other fields you did cast in the way described in your first post work as expected?

Hi, thanks for the reply! No, they don't - all DBLookupListboxes are returning (MEMO). DBGrids are working fine, so that is an option if I'm desperate - but I'd very much prefer to keep certain items as Listboxes.
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

Zvoni

  • Hero Member
  • *****
  • Posts: 2792
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #8 on: December 11, 2024, 07:51:40 am »
I suppose that field isn't the only Text in your database / application - do other fields you did cast in the way described in your first post work as expected?

There were some changes in the sqlite3connection-class

Do you happen to know what these changes are?
https://gitlab.com/freepascal.org/fpc/source/-/issues/40686
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

rvk

  • Hero Member
  • *****
  • Posts: 6640
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #9 on: December 11, 2024, 08:04:36 am »
Which was a poor fix.
Instead of fixing the problem with length for ftString the field was just changed to ftMemo
(which exhibits this problem).

It would have been better to just fix the original problem.

The fix want even for normal tables but for FTS-Tables (virtual tables).
So it introduced more problems than it fixed.

Zvoni

  • Hero Member
  • *****
  • Posts: 2792
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #10 on: December 11, 2024, 08:09:22 am »
Thanks. I tried putting this in the OnGetText event of the field:

Code: Pascal  [Select][+][-]
  1.   Text := Sender.AsString;

Now everything is showing up as blank instead of (MEMO).

you should use "AText"
https://www.freepascal.org/docs-html/fcl/db/tfieldgettextevent.html
Quote
The event handler should return the contents of the field in formatted form in the AText parameter.
Code: Pascal  [Select][+][-]
  1.   aText := Sender.AsString;
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Zvoni

  • Hero Member
  • *****
  • Posts: 2792
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #11 on: December 11, 2024, 08:11:20 am »
Which was a poor fix.
Instead of fixing the problem with length for ftString the field was just changed to ftMemo
(which exhibits this problem).

It would have been better to just fix the original problem.

The fix want even for normal tables but for FTS-Tables (virtual tables).
So it introduced more problems than it fixed.
In hindsight i agree with you.
Yes, it's a poor fix, since it only fixed FTS-tables, but i also wrote in the ticket:
Quote
Though: No idea if it would break anything else.
Yes, i agree the correct approach would be to target the "original" issue with the length

In my defence: I never use DB-Bound controls, so that's the only explanation i can offer
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

heebiejeebies

  • Full Member
  • ***
  • Posts: 139
Re: DBLookupListBox shows (MEMO) in place of the data
« Reply #12 on: December 11, 2024, 09:27:03 am »
Thanks. I tried putting this in the OnGetText event of the field:

Code: Pascal  [Select][+][-]
  1.   Text := Sender.AsString;

Now everything is showing up as blank instead of (MEMO).

you should use "AText"
https://www.freepascal.org/docs-html/fcl/db/tfieldgettextevent.html
Quote
The event handler should return the contents of the field in formatted form in the AText parameter.
Code: Pascal  [Select][+][-]
  1.   aText := Sender.AsString;

THANK YOU! :)

I looked at the past thread and it was also you who solved the original problem by suggesting the SELECT CAST query, too.  For someone who doesn't use DB bound controls, you seem to know a lot about them!

**Nominates Zvoni for canonisation**
Mint 22 Cinnamon / FPC 3.3.1 / L 3.6.0

 

TinyPortal © 2005-2018