Board index » delphi » Master/Detail with two TADOQueries difficulties

Master/Detail with two TADOQueries difficulties

I'm having trouble creating a master/detail with two TADOQueries.

The first SQL is:

SELECT tblGrps.GrpName, tblInv.GrandTotal, tblInv.InvID,tblInv.InvDate,
tblGrps.Street, tblGrps.Telephone,tblGrps.PostalCode, tblContacts.Name,
tblContacts.PhoneNum
FROM tblGrps, tblContacts,tblContGrp,tblInv
WHERE tblContacts.RepID = tblContGrp.ContactID AND
      tblGrps.GrpID = tblContGrp.GrpID AND
      tblGrps.GrpID = tblInv.GrpID AND

and DataSource1.DataSet:=ADOQuery1

The second TADOQuery SQL is:

  object ADOQuery2: TADOQuery
     ...
     DataSource = DataSource1
     Parameters ...
         DataType = ftLargeint
        ...
       end>
     SQL.Strings'  SELECT tblPayments.InvID, tblPayments.PayDate,
                     tblPayments.AmtPaid
FROM tblPayments
WHERE tblPayments.InvID= :paramInvID
   end

When I open both the Detail query (ADOQuery2) returns null.  It appears
that the detail query is not hooked properly on InvID but I can't figure
out why.

Can someone show me the error in my ways?

Thanks,
Bill N

 

Re:Master/Detail with two TADOQueries difficulties


It's late, and I am having difficulties reading...so forgive if I
misunderstand your question.
In order to have an "automatic" master/detail relation between datasets, the
name of the parameter has to be equal to the fieldname it is supposed to be,
ie instead of naming your parameter "paramInvID", call it "InvID".

You also may opt to do things manualy (which I prefer, because it gives you
a little bit more control) . In that case you have to set the parametervalue
each time the master-dataset recordpointer changes, and refresh (close/open)
the detail-dataset. For example in the master-dataset's
datasource.onDataChange

Hope this helps,
Maurice

"Bill N" <ahappyfam...@sympatico.ca> schreef in bericht
news:3E4961AF.9050105@sympatico.ca...

Quote
> I'm having trouble creating a master/detail with two TADOQueries.

> The first SQL is:

> SELECT tblGrps.GrpName, tblInv.GrandTotal, tblInv.InvID,tblInv.InvDate,
> tblGrps.Street, tblGrps.Telephone,tblGrps.PostalCode, tblContacts.Name,
> tblContacts.PhoneNum
> FROM tblGrps, tblContacts,tblContGrp,tblInv
> WHERE tblContacts.RepID = tblContGrp.ContactID AND
>       tblGrps.GrpID = tblContGrp.GrpID AND
>       tblGrps.GrpID = tblInv.GrpID AND

> and DataSource1.DataSet:=ADOQuery1

> The second TADOQuery SQL is:

>   object ADOQuery2: TADOQuery
>      ...
>      DataSource = DataSource1
>      Parameters ...
>          DataType = ftLargeint
>         ...
>        end>
>      SQL.Strings'  SELECT tblPayments.InvID, tblPayments.PayDate,
>                      tblPayments.AmtPaid
> FROM tblPayments
> WHERE tblPayments.InvID= :paramInvID
>    end

> When I open both the Detail query (ADOQuery2) returns null.  It appears
> that the detail query is not hooked properly on InvID but I can't figure
> out why.

> Can someone show me the error in my ways?

> Thanks,
> Bill N

Re:Master/Detail with two TADOQueries difficulties


Thanks Maurice.  It was late for me too.
M. Telkamp
Quote
> It's late, and I am having difficulties reading...so forgive if I
> misunderstand your question.
> In order to have an "automatic" master/detail relation between datasets, the
> name of the parameter has to be equal to the fieldname it is supposed to be,
> ie instead of naming your parameter "paramInvID", call it "InvID".

> You also may opt to do things manualy (which I prefer, because it gives you
> a little bit more control) . In that case you have to set the parametervalue
> each time the master-dataset recordpointer changes, and refresh (close/open)
> the detail-dataset. For example in the master-dataset's
> datasource.onDataChange

> Hope this helps,
> Maurice

> "Bill N" <ahappyfam...@sympatico.ca> schreef in bericht
> news:3E4961AF.9050105@sympatico.ca...

>>I'm having trouble creating a master/detail with two TADOQueries.

>>The first SQL is:

>>SELECT tblGrps.GrpName, tblInv.GrandTotal, tblInv.InvID,tblInv.InvDate,
>>tblGrps.Street, tblGrps.Telephone,tblGrps.PostalCode, tblContacts.Name,
>>tblContacts.PhoneNum
>>FROM tblGrps, tblContacts,tblContGrp,tblInv
>>WHERE tblContacts.RepID = tblContGrp.ContactID AND
>>      tblGrps.GrpID = tblContGrp.GrpID AND
>>      tblGrps.GrpID = tblInv.GrpID AND

>>and DataSource1.DataSet:=ADOQuery1

>>The second TADOQuery SQL is:

>>  object ADOQuery2: TADOQuery
>>     ...
>>     DataSource = DataSource1
>>     Parameters ...
>>         DataType = ftLargeint
>>        ...
>>       end>
>>     SQL.Strings'  SELECT tblPayments.InvID, tblPayments.PayDate,
>>                     tblPayments.AmtPaid
>>FROM tblPayments
>>WHERE tblPayments.InvID= :paramInvID
>>   end

>>When I open both the Detail query (ADOQuery2) returns null.  It appears
>>that the detail query is not hooked properly on InvID but I can't figure
>>out why.

>>Can someone show me the error in my ways?

>>Thanks,
>>Bill N

Other Threads