如何实现ADO查询参数的任意组合

解决方案 »

  1.   

    你是不是做多表查询?直接编写sql语句就可以了
      

  2.   

    可以用SQL的模糊查询啊!很简单的!!举个例子吧!
      ADOQuery.active:=false;
      ADOQuery.SQL.Text:='select * from Deptment where dept like'+quotedstr('%'+iwcombobox2.Text+'%')+'and station like'+quotedstr('%'+iwcombobox3.Text+'%');
      ADOQuery.Active:=true;
    去试试吧!!
      

  3.   

    是不是where后面的条件个数不一定?s:='select * from table where 1=1';
    if edit1.text<>'' then s:=s+' and field1='''+edit1.text+'''';
    if edit1.text<>'' then s:=s+' and field2='''+edit2.text+'''';
    ...
      

  4.   

    可以是动态参数传给ADO里的SQL来执行查询吧!
      

  5.   


    是不是多条件组合查询啊?如果是,用SQL语句查询,DBGrid也会显示符合条件的结果啊!
    SQL='Select * from 数据表名 where'if CheckBox1.Checked =true then  
    begin
     dd(0)=true
     sql=sql +  'CheckBox1所指的字段 ='+ '输入条件值'
    end
    if CheckBox2.Checked =true then 
    begin
     dd(1)=true
     if dd(0) then   //CheckBox1已选中
       sql=sql +  'and CheckBox2所指的字段 ='+ '输入条件值'
     else          //CheckBox1未选中
       sql=sql +  'CheckBox2所指的字段 ='+ '输入条件值'
     end
    if not dd(0) or dd(1) then 
    messagebox('请选择查询方式')  
      

  6.   

    就是where后面的参数不固定啊!
      

  7.   

    很简单,做低归,在HINT 属性设置你的字段或者开始字段,
    如果你想做的好的话,写一个动态组建,我是这样做的
      

  8.   

    那和adoquery也没有关系呀。。
    var 
    sqlstr:string;
    sqlstr:='select * from a where 1=1';
    if edit1.text<>'' then sqlstr=sqlstr+' and 字段='''+edit1.text+'''';
    if ....2.................
    adoquery1.close;
    adoquery1.sql.text:=sqlstr;
    adoqueyr1.open;
      

  9.   

    很死的, 就是拼sql语句,就象很多自动生成sql的工具一样