如何用ADO组件去实现动态的查询,我的意思是用combobox1(用来选择查询条件),然后在edit1文本框里面进行编代码,例如,我在edit1里面输入一个‘广’字,它就会从表里查到所有以’广‘字开头的数据。
非常火急,谢谢!!!

解决方案 »

  1.   

    在edit1的onchange事件里面写并且执行查询语句
      

  2.   

    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('select * from table_name where table_# like '广%'');
    adoquery1.open;
      

  3.   

    Sql.Add('select * from YourTable where '+Trim(ComboBox1.Text)+' like '+'#39'+'%'+Trim(Edit1.Text)+'%'+'#39');
      

  4.   

    Sql.Add('select * from YourTable where '+Trim(ComboBox1.Text)+' like '+'#39'+Trim(Edit1.Text)+'%'+'#39');
      

  5.   

    既然有表存在,一般用dbgrid实现比较好些;
    在edit的onchange事件里写入:
    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.text := 'select distinct field1 from table1 where field1 like ' + quotedstr(edit1.text + '%');
      open;
    end;
      

  6.   


    str:='select * from 表名 where left(字段名,len(trim(edit1.text)))='''+trim(edit1.text)+'''';
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add(str);
    adoquery1.open;
      

  7.   

    sql.text := 'select * from table1 where field1 like ' + quotedstr(edit1.text + '%');//师傅领进门,修行靠个人,不要什么都问,先自己找找答案~~
      

  8.   

    反正就是动态的生成SQL语句了,你用select *就可以得到所有的字段了阿