Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TTable, TQuery, master-detail

76 views
Skip to first unread message

Bruno Lobo

unread,
May 7, 2009, 10:24:02 AM5/7/09
to
Hi All,

I need a master-detail relationship between dbGrids, so the easiest
implementation would be to just use two TTables with the associated
MasterSoure and MasterField specifications. But, I don't see (quite new
to database programming here) how to associate an SQL query string to a
TTable. To circumvent this, instead of using TTables I used two TQueries
in my form, with the necessary SQL statements attached, and
programatically implemented the master-detail relationship. It even works.

But here is the catch: When scrolling the master DBGrid with the mouse
wheel (Delphi 7, with "RowSelec=True" for both dbGrids), the contents of
the detail grid always lags behind the master grid by exactly one mouse
scrollwheel "click". I'll try to make it clearer:

Say both the master and detail grids are showing record 10 data (because
I either clicked on record 10's row on the master grid, or went there
with the arrow keys). Now, if I try to navigate to record 11 with the
scrollwheel, the selection cursor will be on the master grid's record
11, but the detail grid won't change. If I move a further record (now to
12) on the master, THEN the detail grid moves, but to the previous,
record-11 position. Oddly, the master-detail navigation is working
perfectly by clicking or using arrow keys, the problem is just with the
mouse scrollwheel.

That said, I am aware of Delphi 7's grid/mousewheel bug and tried force
a DbGrid Refresh (even a Query.ExecSql) inside the
ApplicatioEventsMessage workaround fix for that bug, but that didn't
work either. I even recompiled the application in Delphi 6 just to make
sure this has nothing to do with the known bug, but that didn't work either.

So I'm left with using TTables and their built-in master-detail
functionality. But, returning to square one, How do I associate SQL
statements to them?

Thanks for any ideas.

0 new messages