比如使用AdoQuery
select * from tDetail
where aaa=:MasterID
and bbb=:MasterID

然后通过tDetail的DataSource连接到dsMaster。
但是我Detail控件里面收不到数据。
怎么办?

解决方案 »

  1.   

    数据查出来了吗?有没有Open/Active?
      

  2.   

    那么Detail也这样做才行的, 那样就也就必要用Master-Detail或者Master-Detail两个数据集都用 SELECT * FROM Master, SELECT * FROM Detail 这样用Master-Detail才有意义, 但是这样效率低.
      

  3.   


    MasterID :='55';
    AdoQuery.close;
    AdoQuery.sql.clear;
    AdoQuery.sql.add(
    select * from tDetail 
    where aaa='+QuotedStr(MasterID)+'
    and bbb='+QuotedStr(MasterID));
    AdoQuery.open
    把你的SQL语句改成这样就OK啦
      

  4.   

    我是在试一种偷懒的方法。
    大家可以肯定的是
    select * from tblMaster // Master
    select * from tblDetail where tblDetail.MasterID=:MasterID//Detail
    然后设置一下adoDetail.DataSource就实现了
    Master变,Detail也变。
    当然,如果多几个参数变量,也是可以实现的。
    问题是,如果多几个是一样的,都是MasterID怎么办?
    有没有谁碰到过?
    分不够可以加。
      

  5.   

    不要说是  select * from tDetail 
    where aaa=:MasterID 
    and bbb=aaa这个答案偏题了,不是我想知道的。
      

  6.   

    从来么遇见过。。
    不知道你要求的功能是什么。。 select   *   from   tDetail   
    where   aaa=:MasterID   
    and   bbb=aaa这样确实可以。。= =!帮你顶
      

  7.   

    adoquery1.Parameters.ParamByName('pt').Value := l1.Caption;
    adoquery1.Parameters.ParamByName('pe').Value := l1.Caption;
    adoquery1.close;
    adoquery1.Open;这样不行?
      

  8.   

    adoquery1.Parameters.ParamByName('pt').Value   :=   Matabelid;
    adoquery1.Parameters.ParamByName('pe').Value   :=   Matabelid; 
    adoquery1.close; 
    adoquery1.Open; 
    放到 dsMaster 的 DataSource 的 ondatachenage 里
      

  9.   

    尽管没有试,但是我觉得 10楼 GYQ2HPP 的方向是最接近的。