Board index » delphi » TQuery Master/Detail linked with other DataSource

TQuery Master/Detail linked with other DataSource

I can create a Master/Detail relation with the MasterSource and MasterField
properties of the TTable component. How can I do it with a TQuery component?

Ass.: Gilberto Santos
gilbe...@isicom.pt

 

Re:TQuery Master/Detail linked with other DataSource


Quote
Gilberto Santos <gilbe...@isicom.pt> wrote in message

news:7s8fjt$i5p$1@news.EUnet.pt...

Quote
> I can create a Master/Detail relation with the MasterSource and
MasterField
> properties of the TTable component. How can I do it with a TQuery
component?

Try to put key field seach connditions into WHERE construction of the Detail
query.
It adds parameters that  MasterSource will use for selecting data.

For example:
Master - Detail by field1 & field2

Detail query:
select * from table where condition
                                                    AND field1=:field1 AND
field2=:field2

I did not try this with TQuery but with TClienDataSets it works.

Re:TQuery Master/Detail linked with other DataSource


On Tue, 21 Sep 1999 18:35:08 +0100, "Gilberto Santos" <gilbe...@isicom.pt>
wrote:

Quote
>I can create a Master/Detail relation with the MasterSource and MasterField
>properties of the TTable component. How can I do it with a TQuery component?

First, add a parameter to the SQL statement in the Detail TQuery. The
parameter should have the same name as the field in the Master TQuery that
is used to associate (link) the records between the two query components.
For example, the sample Paradox tables Customer (as Master) and Orders (as
Detail) have the field CustNo in common and on which their relation is
based. So the SQL statement for the Detail TQuery would look like this:

  SELECT *
  FROM Orders O
  WHERE O.CustNo = :CustNo

The second step is to set the DataSource property of the TQuery to point to
the TDataSource component used to display the Master TQuery data. For
example, if the Master TQuery is Query1 and its data is displayed in
data-aware controls using DataSource1, you would set the DataSource
property of Query2 (the Detail TQuery) to DataSource1. The data from Query2
could still be displayed through data-ware controls using a different
TDataSource.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

Other Threads