我想做一个这样的程序,
我用的数据库为INterBase我想做一个动态的查询功能,如给用户多个选择项让他来自己进行查询对所选择的内容进行复合查询请个位给于意见,如果有相关的源代码请告诉一下或者是网站。
谢谢

解决方案 »

  1.   

    你可以先把数据库的各字段译成汉语(建立一一对应关系,汉字提供给用户,用户是不懂你数据库的字段意思的);然后用一两个listbox,一个显示数据库的所有的字段,然后放一个按钮,让用户去选择要查询的字段,把要查询的字段添加到另一个listbox中,然后根据上边建立的一一对应的关系,再泽成数据库的对应的字段,然后查询,显示出来,就可以了;
      

  2.   

    方法太多种了,控件也太多了
    纯粹是SQL语句的应用
      

  3.   

    sqlstr:='select * from xx where 1=1'if edit1.text<>'' then
     sqlstr:=sqlstr+' and ...';
    if checkbox1.checked then
     sqlstr:=sqlstr+' and....';
    if combobox1.itemindex>0 then
     sqlstr:=sqlstr+' and....';...就这样就可以了
      

  4.   

    把相应的表的字段列出来,写出相应的含义,这样在用户选择完之后,根据选择的字段添入SQL语句,这个之前就可以判断然后连接出复合语句就可以得到SQL语句,执行~
      

  5.   

    var
    str:string;
    begin
     if edit1.Text<>'' then
       str:='where 性别='+edit1.Text+''
     else
       str:='';
     if edit2.Text<>'' then
      begin
       if edit1.Text='' then
        str:= 'where kkk='+edit2.Text+''
       else
        str:=str+'and kkk='+edit2.Text+'' ;
      end else
       str:=str;
     if edit3.Text<>'' then
      begin
       if (edit1.Text='') and (edit2.Text='') then
       str:= 'where www='+edit3.Text+''
       else
        str:=str+'and www='+edit3.Text+'' ;
      end else
       str:=str ;
    SQL语句、、、
      

  6.   

    var
    sarray:array[1..4]of string;
    sboolean:boolean;
    sstr:string;
    i:integer;
    begin
     if c1.Checked=true then
           sarray[1]:='日期>='+''''+formatdatetime('yyyy-mm-dd',d1.date)+''''+' and 日期<='+''''+formatdatetime('yyyy-mm-dd',d2.date)+''''
         else sarray[1]:='';
     if c2.Checked=true then sarray[2]:='车型='+''''+sncombobox1.Text+''''
        else sarray[2]:='';
     if c3.Checked=true then sarray[3]:='颜色='+''''+sncombobox2.Text+''''
        else sarray[3]:='';
     if c4.Checked=true then sarray[4]:='类别=''出口车'''
        else sarray[4]:='';
      sboolean:=true;
      sstr:='';for i:=1 to 4 do
      begin
        if sarray[i]<>'' then
        begin
         if sboolean=true then
           begin
            sstr:=sstr+sarray[i];
            sboolean:=false;
           end
         else sstr:=sstr+' and '+sarray[i];
        end;
       end;
      if sstr='' then exit
        else sstr:=' where '+sstr;  adoquery1.Close;
      adoquery1.SQL.Clear;
      sstr:='select * from tablename'+sstr;
      adoquery1.SQL.Add(sstr);
      adoquery1.open;
    其中c1,c2,c3,c4是checkbox
      

  7.   

    问题是如果程序中包括 and or like 的话程序应该如何来写。请给予指正