界面上有5个text输入框,要求在输入框中输入数据(条件),就可以对数据集进行过滤查找,不一定每个框都是全部有输入的,可以缺省的,使数据集同样变化,该如何简便控制啊,5各输入框啊????

解决方案 »

  1.   

    没有的你就用条件 like '%%'
    然后自己写条件。
      

  2.   

    你用的时BDE还是ADO
    例子(ADO),在adoquery里写:
    declare @a varchar(10),@b varchar(10)...
    Select *From 表 
          where (@a = '' or 字段a = @a) and (@b = '' or 字段b=@b)...
    这样传出了参数,在程序中给@a,@b...赋edit框的值就可以了,edit框里为空时表示该字段不处理
      

  3.   

    用like:
    StrSql:='select * from table '+
    'where field1 like ''%'+Edit1.text+'%'' '+
    'and field2 like ''%'+Edit2.text+'%'' '+
    'and field3 like ''%'+Edit3.text+'%'' '+
    'and field4 like ''%'+Edit4.text+'%'' '+
    'and field5 like ''%'+Edit5.text+'%''';
      

  4.   

    Str: String;
    begin
      Str := '';
      if edit1.text <> '' then
        Str := Str + 'where field = ' + edit2.text;
      if edit2.text <> '' then
        Str := Str + 'and field = ' + edit2.text;
      ....
    end;
      

  5.   

    StrSql:='select * from table '+
    'where field1 like ''%'+Edit1.text+'%'' '+
    'and field2 like ''%'+Edit2.text+'%'' '+
    'and field3 like ''%'+Edit3.text+'%'' '+
    'and field4 like ''%'+Edit4.text+'%'' '+
    'and field5 like ''%'+Edit5.text+'%''';
      

  6.   

    var str:string;
    begin
      str:='';
      if edit1.text<>'' then 
        begin
          str:=str+'field1='''+edit1.text+''''+' and  '
        end;
    .....
    str:=copy(str,1,length(str)-5);