Board index » delphi » Master Detail using Queries

Master Detail using Queries

I have implemented a master detail setup using 2 queries and setting
the datasource of the detail to the datasource of the master.

My question is: For a specified master, how can I easily determine
its child? (generically speaking)

--
Bruce Swart

 

Re:Master Detail using Queries


Quote
> My question is: For a specified master, how can I easily determine
> its child? (generically speaking)

General answer:
I think that you have to start with a child and look for its master.
Remember that you can have a few detail blocks for one master.

Marek

Re:Master Detail using Queries


On Thu, 04 Jun 1998 12:56:08 +0200, Bruce Swart <bru...@cm.co.za>
wrote:

Quote
>I have implemented a master detail setup using 2 queries and setting
>the datasource of the detail to the datasource of the master.

>My question is: For a specified master, how can I easily determine
>its child? (generically speaking)

Use TDatabase's DataSets (and DataSetCount) properties to loop through
all of them, finding out from the DataSource property if it's a child
of the specified master. Something like:

procedure TForm1.ShowLinkedQueries;
var
  Counter: integer;
begin
  for Counter := 0 to Database1.DataSetCount - 1 do
    if Assigned(Database1.DataSets[Counter].Datasource) then
      ShowMessage(Format('%s links to %s'
                        ,[Database1.DataSets[Counter].Name

,Database1.DataSets[Counter].DataSource.DataSet.Name]));
end;

Works only on active datasets, though.

Happy programming.

Jasper

Other Threads