我做了一个书籍的数据库 并用DBLookupComboBox对其里面的出版社这个字段名进行查询但是我现在在DBLookupComboBox里面只能显示出版社 但是不能进行选择 我希望得到的是下面的DBGrid根据DBLookupComboBox里面选择不同的出版社进行相应的查询
请告诉我怎么做才能实现
我的数据库名是book 出版社的字段名是PName

解决方案 »

  1.   

    DBLookupComboBox不是用来做查询的。
    作查询建议使用TMS的dblucombobox
      

  2.   

    用TCombobox控件
    初始化部分:
    qry.Close ;
    qry.SQL.Clear ;
    qry.SQL.Add('select ÍD,NAMe from PUBLISHS');
    qry.Open;
    combobox1.Items.Clear ;
    while not qry.EOF do
    begin
      combobox1.Items.Add(qry.FieldByName(ÍD').AsString+'.'+qry.FieldByName('NAME').AsString);
    end;在Combobx1的的Change事件中
    var
      id : string ;
    begin
      id := combobox1.Text ;
      id := copy(id,1,pos('.',id)-1) ;
      qryResult.Close ;
      qryResult.SQL.Clear ;
      qryResult.SQL.Add('select * from Books');
      qryResult.SQL.Add('where publish_ID='''+id+'''') ;
      qryResult.Open ;
    end;这里qryResult是查询的结果集。不知是否符合你的要求。
      

  3.   

    我用的不是TCombobox 而是DBLookupComboBox我想知道这个的代码怎么写