怎么样通过控件连接SQL数据库并在控件中同时显示2个表以上的信息  然后添加一个查询功能(可以在显示的信息中查询到所需要的信息)?
我 只知道使用DBGrid控件显示一个表的信息  并实现查询功能代码如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
 with Query1 do
 begin
   SQL.Clear;
   SQL.Add('Select * from ClientBInfo where CACC like :CACC');
   Case RadioGroup1.ItemIndex of
     0:parambyname('CACC').AsString:=edit1.Text;
     1:parambyname('CACC').AsString:=edit1.Text + '%';
    end;
    open;
  end;
end;

解决方案 »

  1.   

    多表联合查询不就行了。比如左连接:
    select a.*,b.* from a left join b on a.xxx=b.xxx
     where xxxx
      

  2.   

    主从表
    或者用Lookup控件。
    推荐用cxGrid。
      

  3.   

    cxGrid控件 在哪找 
    还有我 是 新手
    主从表怎么 弄啊
      

  4.   

    怎么联合查询啊  查询语句是:??
    需要把下面4个表查询出来以“CACC”为查询字段,要求每个表的字段信息全部显示出来!! 表WaterMeterInfo 
    字段名: CACC  MeterNo  Seq  LabelNo   PhysicsNo Password Type BalMode WMLoc WMSNum WMBNum Model LastPurChaseTime PurchaseTimes WProTypeCode HisArrear AIndicator ReimbursementStatus   VirtualPhysicsNo   VirtualLabelNo GetNoFrom Is  CreateRealNo caliber unit CreateDate  ModBy ModDate 表ClientBInfo 
    字段名:CACC Name ID Address Phone OpenBuCode OpenOpCode OpenDate LogOpCode LogDate LgOutBuCode CreateBy CreateDate ModBy ModDate AIndicator 
    表ClientWInfo 
    字段名:CACC PNum AIndicator OpenBuCode OpenOpCode OpenDate LgOutOpCode LgOutDate  LgOutBuCode CreateBy  CreateDate ModBy ModDate Re surplus 
    表SellsInfo 
    字段名: CACC  Seq Sdate CbuinCode MeterNo LabelNo MeterType MeterModel  Samt Sstere SopertCode SbusinCode Ptype
      

  5.   


        cxGrid       Lookup控件 
    在哪找到说下哦