with adoquery1 do
 begin
  close;
  clear;
  sql.add('select * from table1 where table1.co1 like "%:aa%"');
  parameters.ParamByName('aa').value=edit1.text;
  open;
 end;

解决方案 »

  1.   

    模糊查询语句的格式:Select * From Table Where Column1 Like '%adf%'自己看看错在哪里吧!!
      

  2.   

    aa是你的表中的一个字段吗?我看不象,好像是你自己定义的一个变量。如果是这样的话出错就正常了,把:paramByName('aa')中的aa改成相对应的字段名
      

  3.   

    如果 edit1.text 的内容是 abcd
    sql.add('select * from table1 where table1.co1 like %:aa%');
    你的这句会变成select * from table1 where table1.co1 like %'abcd'%
    你说会对吗?
      

  4.   

    或with adoquery1 do
     begin
      close;
      clear;
      sql.add('select * from table1 where co1 like "%'+edit1.text+'%"');
      open;
     end;
    其中的table1.co1写成col就可以了
      

  5.   

    嘻嘻
     CoolSlob(),一点点~~~
      

  6.   

    sql.add('select * from table1 where table1.co1 like ''%:aa%''');
    parameters.ParamByName('aa').AsString=edit1.text;
      

  7.   

    sql.add('select * from table1 where co1 like "%'+edit1.text+'%"');
      

  8.   

    'select * from table1 where table1.co1 like "%:aa%"
      

  9.   

    老是出现这样的提示:
     project project1.exe raised exception class eoleexception with
    message 'invalid column name '%n%'',process stopped,use step or run
    to continue!
    这是什么意思,哪位高手可以帮帮我!
      

  10.   

    假设
    aa为string类型变量var str,aa:string;aa:=edit1.text;
    str:='select * from table1 where table1.co1 like%:'+aa+'%';with adoquery1 do
     begin
      close;
      clear;
      sql.add(str);
      open;
     end;这种情况更本不能使用ParamByName('aa').这样的语句
      

  11.   

    已经试出两种正确的方法:
     1.with adoquery1 do
       begin
        close;
        clear;
        sql.add('select * from table1 where col  like ''%'+edit1.text
           +'%''');
        open;
       end;
     2.另一种在flyingice(ygxdha)方法上改进一下:
        var
        aa,str:string;
        aa:=edit1.text;
        str:='select * from table1 where col like ''%'+aa+'%''';
        with adoquery1 do
         close;
         clear;
         sql.add(str);
         open;
        end;
      

  12.   

    呵呵,忘记加'了。
    这种情况我们通常是使用format函数的。
      

  13.   

    也可以像dejoy(燕青) 所说的用参数:
    with adoquery1 do
     begin
      close;
      sql.Clear;
      sql.add('select * from table1 where table1.co1 like :aa');
      parameters.ParamByName('aa').value:='%'+(edit1.Text)+'%' 
      open;
     end;