cPY:string;
cSQL:string;
begin
  cPY:=edit1.Text;
  cSQL:='select bh,xm,py from XMPY where py like"'+cPY+'"%'//?
上面 的那句sql语句应该怎么表示啊
with DataHJZL.AdoQueryTMP do
   BEGIN
    Close;
    SQL.Clear;
    SQL.Add(cSQL);
    Open ;
   end;
end;

解决方案 »

  1.   

    cSQL:='select bh,xm,py from XMPY where py like '+quotedstr(ecpy+'%');
      

  2.   

    cPY:string;
    cSQL:string;
    begin
      cPY:=edit1.Text;
      cSQL:='select bh,xm,py from XMPY where py like '''+cPY+'%'''
    with DataHJZL.AdoQueryTMP do
       BEGIN
        Close;
        SQL.Clear;
        SQL.Add(cSQL);
        Open ;
       end;
    end;
      

  3.   

    cSQL:='select bh,xm,py from XMPY where py like'+''''+cPY+''''+'%'
    注意'的个数不能写错!
      

  4.   

    cSQL:= fromat('select bh,xm,py from XMPY where py like ''%s%%''',[参数])
    你是不是想实现模糊查询?
    试试?
      

  5.   

    cSQL:='select bh,xm,py from XMPY where py like '+#39+cPY+'%'+#39;