我想对报刊信息进行模糊查询。查询方式(按报刊名称和邮发代号查询)用ComboBox给出,用户可以自由选择,然后在Edit中输入查询的关键字开始查询,显示报刊的所以信息。请问代码怎么写?如何显示查询结果,怎样显示比较好?另外,劳烦各位在讲解时可以详细点,多谢了!对了,我是用ADO连接的

解决方案 »

  1.   

    if ComboBox.text='报刊名称' then
       ADOQUERY.SQL.add('select * FROM 表名 where 报刊名称='+'''' + edit.text + '''')
    elseif ComboBox.text='邮发代号' then 
       ADOQUERY.SQL.add('select * FROM 表名 where 邮发代号' ='+'''' + edit.text + '''')
      

  2.   

    adoquery1.sql.add('select * from tablename wehre :combobox = :edit');
    adoquery1.parameters[0].values:=combobox1.text;
    adoquery1.parameters[1].values:=edit1.text;
    adoquery1.open;
    没有测试,不知可不可以!
      

  3.   

    楼上的太烦
    ADOQUERY.SQL.add('select * FROM 表名 where 报刊名称='+'''' + edit.text + '''')
    报刊名称处也可动态的取啊
      

  4.   

    combobox 搞什字典表
    字段名是英文显示为中文 
    adoquery1.sql.add('select * from tablename wehre :combobox = :edit');
    adoquery1.parameters[0].values:=; //combobox1.text这里从字典表中取字段名
    adoquery1.parameters[1].values:=edit1.text;
    adoquery1.open;
      

  5.   

    还是建议你用参数来做,增加可读性,如果你要用blueshu(绝对是菜鸟)的方法也行,但要小心别忘了一个'不然就麻烦了
      

  6.   

    人家都说了是模糊查询了--------------------------follow me!
      if Trim(StationName.Text)<>'' then
        lSql:=lSql+' and StationName like "%'+Trim(StationName.Text)+'%"';你自己改改就可以了GOD BLESS YOU!
      

  7.   

    用了ADOQUERY或者adodatabase索引和需要的字段就可以了
    select field1,field3,field..   from table where ....
      

  8.   

    to qxj(小小小小小小程序员)怎么用参数???
      

  9.   

    adoquery中用like ;
    adoquery1.close;
    adoquery1.clear;
    adoquery1.sql.add('select * from tablename wehre 报刊名称 like :edit');
    adoquery1.parameters.parabyname('edit').values:='%' + trim(combox1.text) + '%';
    adoquery1.open;