想实现:
按dbcombobox中的item a,b,c...时,对应DBGird中显示name项为a的所有数据!我是这么写的,但没用,为什么?
dbcomboboxchange()
begin
  query1.close;
  query1.clear;
  query1.sql.add('select * from tableaaa where name='+dbcombobox1.text);
  query1.open;
close;

解决方案 »

  1.   

    你最好确定你的DBGID已经连接到了数据源
      

  2.   

    bcomboboxchange()
    begin
      query1.close;
      query1.clear;
      query1.sql.add('select * from tableaaa where name='+quotedstr(dbcombobox1.text));
      query1.open;
    close;
      

  3.   

    dbcomboboxchange()
    begin
      query1.close;
      query1.clear;
      query1.sql.add('select * from tableaaa where name='''+dbcombobox1.text+'''');
      query1.open;
    close;
    连接是否一致?
      

  4.   

    连接一致。select *from tableaaa 能显示全部.
      

  5.   

    把sql取出来,到数据库中执行一下看看。
      

  6.   

    不妨用一个中间变量,赋值为dbcombobox.text
      

  7.   

    dbcomboboxchange()
    begin
      query1.close;
      query1.sql.clear;  //这里应该是SQL。CLEAR吧
      query1.sql.add('select * from tableaaa where name='''
                      +trim(dbcombobox1.text)+'''');
      query1.open;
    close;
    这样你试试