Recent

Author Topic: dblookuplist question  (Read 3142 times)

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
dblookuplist question
« on: December 11, 2019, 02:05:17 am »
Hi,

I've just gone back to a development which worked, burr now the DBLookupList isn't working.  I can't select a list item or multiple list items,  where previously I could and it worked.  When I select an item it highlights but then immediately dehighlights?

Has anyone else seen this?

Thanks
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: dblookuplist question
« Reply #1 on: December 12, 2019, 10:21:35 am »
Any thoughts on this?
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: dblookuplist question
« Reply #2 on: December 12, 2019, 11:16:05 am »
Hello,

what do you call a dbLookupList: a dbLookupListBox?
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: dblookuplist question
« Reply #3 on: December 12, 2019, 11:51:57 am »
@daveinhull

Do you have a backup? Maybe you accidentally modified something, so it doesn't work now. Try the code from backup first.

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: dblookuplist question
« Reply #4 on: December 13, 2019, 12:15:56 am »
Hi @Handomo,

Thanks for the comment and suggestion. Yes I tried a backup and I also tried adding a new component ,but it does the same thing.

I'm using the latest version of Lazarus.

Can someone confirm that they have it working, then I guess I know it's my error.

Thanks
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: dblookuplist question
« Reply #5 on: December 13, 2019, 12:26:59 am »
If you'd provide a compilable project here (ideally simplified and using only a standard database) I could try to verify the issue.

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: dblookuplist question
« Reply #6 on: December 14, 2019, 02:26:45 pm »
tl;dr;

https://bugs.freepascal.org/view.php?id=35069

Is it this case?
If so, it is broken at last from spring 2019.
Initially, I reported it as minor one, although in fact it is important (I had to switch to another control), but unfortunately I can't change bug priority.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: dblookuplist question
« Reply #7 on: December 15, 2019, 01:44:11 pm »
Hi sash,

Yes that looks like it.

I've attached a zip file with a simple test programe to show the problem.
I've just used an access database (also included).
If I've missed something from the zip file please let me know.
PS this is on wndows.

Hope someone can fix it :-)

Dave
« Last Edit: December 15, 2019, 01:46:09 pm by daveinhull »
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: dblookuplist question
« Reply #8 on: December 15, 2019, 03:38:10 pm »
This is not a bug. You have not set DataSource and DataField properties. It doesn't work without these properties, just like TDBEdit or other data-aware controls.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: dblookuplist question
« Reply #9 on: December 15, 2019, 04:14:28 pm »
Hi sash,

Yes that looks like it.

I've attached a zip file with a simple test programe to show the problem.
I've just used an access database (also included).
If I've missed something from the zip file please let me know.
PS this is on wndows.

Hope someone can fix it :-)

Dave
Strange demo: database not connected, dataset not active, no code - why do you need the Access database after all? But it reminds me of the "unbound use"  of the DBLookuoCombobox. I do remember that there was an issue, and I think it has been fixed.

And indeed, I do not see the issue when I compile and run your demo with Laz trunk, but I do see the reported behavior with Laz 2.0.6. Looking at the svn commit notes of dblookuplistbox.inc there is a commit by Juha which might have fixed it (r61111, May 3 2019). In the discussion of the report there are some open points which might have been the reason why the report has not been resolved and thus did not make it into v2.0.6.

Please test the issue with Lazarus trunk and confirm that the issue is solved indeed, and also that there are no sideeffects - fixing bugs in the data-aware controls really is a pain!
« Last Edit: December 15, 2019, 04:16:00 pm by wp »

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: dblookuplist question
« Reply #10 on: December 15, 2019, 04:38:39 pm »
In my opinion, there is no such thing like "unbounded data controls". Data-aware controls are designed to operate with a selected data field (properties DataSource,DataField) and what they display closely reflects value of indicated data field.
So if you need a combo box with items coming from database just use TComboBox and populate items from dataset.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: dblookuplist question
« Reply #11 on: December 15, 2019, 04:51:56 pm »
In my opinion, there is no such thing like "unbounded data controls". Data-aware controls are designed to operate with a selected data field (properties DataSource,DataField) and what they display closely reflects value of indicated data field.
I forgot to add the wiki link: https://wiki.freepascal.org/TDBLookupComboBox#Unbound_use. The word "unbound" is maybe misleading, but have only one dataset attached to a lookup control, instead of two, DOES make sense in some cases.

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: dblookuplist question
« Reply #12 on: December 15, 2019, 05:33:56 pm »
I forgot to add the wiki link: https://wiki.freepascal.org/TDBLookupComboBox#Unbound_use. The word "unbound" is maybe misleading, but have only one dataset attached to a lookup control, instead of two, DOES make sense in some cases.
Maybe just use some in-memory dataset for this purpose? It would be simpler and clearer than the advice from wiki page.
I know that Delphi allows unbounded lookup controls, but lookup controls in delphi have a completely different architecture. But I think it is a bug that was used as a feature (side effect?).

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: dblookuplist question
« Reply #13 on: December 16, 2019, 09:24:00 am »
All,

@wp,
Don't understand, everything is connected and active in my version!!!
Don't need code to just show you the problem with trying to set multiple list entries.

Ok, so how do you store multiple selected list items in a data feild?

What I was doing, maybe wrongly, was catching the on click, finding out which list entries had been set, creating a list and storing the list in the database field - wrong???

I thought I was trying it with trunk, isn't that the official released version, v2.0.6?

Dave

Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: dblookuplist question
« Reply #14 on: December 16, 2019, 11:16:01 am »
Don't understand, everything is connected and active in my version!!!
I downloaded your zip again and looked at the LFM file again, but now outside the IDE. Yes, you are right: the ODBCConnection has Connected = true, the database file is specified in its Params.Strings, and the Query is Active. But when I load your project into the IDE, the ODBConnection.Connected is false, and the Query.Active is false, as well. What's going on here?

It is the way you specify the location of the database file. You specify it as a relative path. This is wrong, never use relative paths in relation to database components. At designtime this is relative to the Lazarus folder! I wonder how you were able to establish the ODBCConnection in the first place. Therefore, I was missing code in the FormCreate event or similar, to explicitly open the database:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   ODBCConnection1.Connected := true;
  4.   SQLQuery1.Active := true;
  5. end;  

With this event handler in place I can see the items in the LookupListbox. And using Laz trunk (-- see below, on what that is) every item can be selected, and the selection does not disappear after each click (I cannot select several items, and I doubt if that is possible because there is nothing like "MultiSelect" or so among the properties of the DBLookupListBox).

When I compile with Laz 2.0.6 I see the behavior that you describe: When I press the mouse button on an item the item is highlighted, but when I release the mouse button, the highlight goes away.

Laz trunk is the development version, i.e. the version into to all new code is added primarily, all new features, all bug fixes.
Laz 2.0.6 is the last release version, i.e. a snapshot of the trunk version taken some time ago when the developers decided: "OK, let's release this now".
When bugs appear after taking this snapshot and releasing the version their fixes are copied from the trunk version to a special branch of the version tree called "Fixes". It always has odd version numbers, i.e. it is version 2.0.7 for the current release. From time to time a new release of the bug-fixed version will be published, now with an odd number again, here: 2.0.8.

"Your" bug is a bit complicated. According to the svn commit notes, it has been fixed in trunk, but there seem to open issues (https://bugs.freepascal.org/view.php?id=35458). Or it simply has been forgotten - we're only human...). As a consequence, the issue has not been "resolved", and without this step the patch is not back-ported to fixes. I'll contact Jesus Reyes to whom the original issue has been assign.

 

TinyPortal © 2005-2018