程序:
var
 ProID:String;
 with ADOQuery1 do
 begin
   CLose;
   SQL.Clear;
   SQL.Add('select * from Table1 where ID like :ID');
   Parameters.ParamByName('ID').value:=ProID+'%';
   Open;
 end;这样找不出来,也试过
 with ADOQuery1 do
 begin
   CLose;
   SQL.Clear;
   SQL.Add('select * from Table1 where ID like '''+ProID+'%''');
   Open;
 end;
也找不出来

解决方案 »

  1.   

      SQL.Add( 'select   *   from   Table1   where   ID   like'+  QuotedStr(+ProID+ '% '));
      

  2.   

       sql.text := 'select * from clientinfo where groupName like :mypar';
       parameters.ParamByName('mypar').Value:='%'+edit1.Text+'%';
      

  3.   

    ID如果是integer类型的话,要先转换,你可以改成这样看看
      with   ADOQuery1   do 
      begin 
          CLose; 
          SQL.Clear; 
          SQL.Add( 'select   *   from   Table1   where   cast(ID as varchar(20)) like :ID '); //改 
          Parameters.ParamByName( 'ID ').value:=ProID+ '%'; //%之前无空格 
          Open; 
      end; 
      

  4.   

    liuhengwinner 
    let it be 
    等 级:
     发表于:2007-11-21 12:07:093楼 得分:0 
          sql.text   :=   'select   *   from   clientinfo   where   groupName   like   :mypar '; 
          parameters.ParamByName( 'mypar ').Value:= '% '+edit1.Text+ '% '; 
    ---------------------------
    这个方法不行,找不到
      

  5.   

    adoQuery1.parameters.ParamByName(   'mypar   ').Value:=   '%   '+edit1.Text+   '%   ';   
      

  6.   

    Adoquery1.parameters.ParamByName(   'mypar   ').Value:=   '%   '+edit1.Text+   '%   ';   
      

  7.   

    ly_liuyang 
    LYSoft (http://G4Soft.Net) 
    等 级:
     发表于:2007-11-21 13:08:139楼 得分:0 
    一向用用Format~这个更好 
    -------------------------------
    怎么用? 
      

  8.   

    SQL.Text:=Format('select * from clientinfo where groupName like ''%s%%''',[ProID]);
      

  9.   

    你要是实在行,你可以用SHOWMESSAGE(AODQUERY1.SQL.TEXT);
    这样可以自检SQL语句是否正确
      

  10.   

    先把SQL语句在查询分析器中试试..
      

  11.   

    var
      s: string;
    begin
      s:='71-5a';
      ADOQuery2.Close ;
      ADOQuery2.SQL.Clear ;
      ADOQuery2.SQL.Text :='select   * from  part1 where id_ like ''%'+s+'%''';//这样OK,
      

  12.   

      with   ADOQuery1   do 
      begin 
          CLose; 
          SQL.Clear; 
          SQL.Add( 'select   *   from   Table1   where   ID   like   ' ' '+'ProID'+ '% ' ' '); 
          Open; 
      end; 
      

  13.   

      with   ADOQuery1   do 
      begin 
          CLose; 
          SQL.Clear; 
          SQL.Add( 'select   *   from   Table1   where   ID   like   ' ' '+ProID+ '''% ' ' ); 
          Open; 
      end; 
      

  14.   

    大家都是高手呀
    菜鳥想問一下:parameters.ParamByName(   'mypar   ').Value:=   '%   '+edit1.Text+   '%   ';  什么意思
      

  15.   

    SQLText := Format('select * from table1 where col like %s', [QuotedStr('%' + Edit1.text + '%')]);
      

  16.   

    晕,,,一个LIKE问题搞了这么长时间,,
      

  17.   

    还有一个问题大家可能没有注意到,数据库用的是什么,用SQL2000,oracle,或是用access "like"用法都有些小的不同.