with query1 do
begin
  close;
  sql.clear;
  SQL.Add('select * from subsidary where pname=''s\''pore'''); 
  //search the record it's name is s'pore
  open;
  if IsEmpty then
    showmessage('no record');
  close;
end;
有报错:"Missing right quote.", 用参数的方法可以处理,但为什么此方法不行?
thks.

解决方案 »

  1.   

    楼上,你是说:pname=+'''' + s''pore + ''''吗?不行
      

  2.   

    SQL.Add('select * from subsidary where pname='+''''+'s\'+''''+'pore'+''''); 
    如果你是要查找Pname=s'pore的记录的话
      

  3.   

    楼上,你有试吗?我的mysql版本是3.23.47,还是不行,我可再等
      

  4.   

    with query1 do
    begin
      close;
      sql.clear;
      SQL.Add('select * from subsidary where pname=''''s\''''+char(39)+''''pore'''''); 
      //search the record it's name is s'pore
      open;
      if IsEmpty then
        showmessage('no record');
      close;
    end;
      

  5.   

    SQL.Add('select * from subsidary where pname='+''''+'s'+''''+'+'+''''+''''+''''+''''+'+'+''''+'pore'+''''); 不好意思长了点(我水平有限),但是可以实现。我试过了。
      

  6.   

    为什么要用逗号呢?
    有QUOTEDSTR()为什么不用?
    SQL.Add('select * from subsidary where pname='+quotedstr('......'));
      

  7.   

    with query1 do
    begin
      close;
      sql.clear;
      SQL.Add('select * from subsidary where pname=''s\''+char(39)+''pore'''); 
      //search the record it's name is s'pore
      open;
      if IsEmpty then
        showmessage('no record');
      close;
    end;
    --------------------------------------------------------------------------------
    不好意思,刚刚写错了,惭愧!
      

  8.   

    Ok, I get it.Thaks quys, specially for  peterluolaw(木瓜).  with query1 do
      begin
        close;
        sql.clear;
        SQL.Add('select * from subsidary where pname=' + quotedstr('s''pore'));
             //search the record it's name is s'pore
        showmessage(sql.text);
        open;
        if IsEmpty then
          showmessage('no record')
        else
          showmessage(inttostr(recordcount));
        close;
      end;