主表:用了一个adoquery,sql为:select * from doctor;在表doctor里有一个doc_state字段,现在我想当doc_state为2时,从表就不显示数据,当不为‘2'时,从表就显示select * from patient.
如何实现??
我本来想写select * from patient where :doc_state<>'2' 但通不过

解决方案 »

  1.   

    doc_state可是字符段??
    '2'是字符串
      

  2.   

    u used 2 TADOTable(suppose tbDoctor,tbPatient)?
    did u use TDataSource (suppose dsDoctor)associated to the tbDoctor
    and set tbPatient.MasterSource:=dsDoctor??
      

  3.   

    另外,不妨試
    where not :doc_state='2'
      

  4.   

    也可以用
    Filter来过滤数据
    Filtered := false;
    filter := ' doc_state =  ' + QuotedStr('2');
    Filtered := true;
      

  5.   

    用Client-Side filtering也是一個不錯的選擇
      

  6.   

    select * from patient where :doc_state<>'2' 
    :doc_state<>'2'是不是不能这样写,当这个从表的adoquery open时,提示错误parameter对象被不正确定义,提供了不一致或不完整的信息
      

  7.   

    首先主表要比從表先打開才行
    第二請注意看看ObjectInspector關於Parameter的ParamType