字符串S1值为:
select * from abc where aa='123' and bb='234' and cc='456' and dd='567' and ee='678'      (全是单引号)我怎样将上面的值变成select * from abc where aa=''123'' and bb=''234'' and cc=''456'' and dd=''567'' and ee=''678''      (全变成双引号)
补充:
单引号的数量和位置不确定  

解决方案 »

  1.   

    先用pos函数,查找’号的位置,然后在’号前面再加一个’不过我看楼主的意思好像是要写SQL,如果是要写SQL的话,字段类型是肯定先能知道的。‘’中的是数字型字段,‘‘’’中的是字符类字段如果你要查找的字段是数字型的,用‘’,如果是字符型的用‘‘’’就可以了,跟具体的值没关系。为什么要换呢?而且数据集组件的 ASInteger方法,可以直接把纯数字的字符型字段转换为整型。就算是要在一个字符型字段中一个纯数字也没必要重新建一个Int字段啊。
      

  2.   


    //用StringReplace,示例如下
    StringReplace('abcd','b','e',[rfReplaceAll,rfReplaceAll]);
      

  3.   

    StringReplace(S,''','"',[rfReplaceAll,rfReplaceAll]);
      

  4.   

    procedure TfrmSmsSend.ReplaceStr(var s: string; const Source, Des: string);
    var
      I:Integer;
    begin
      I:=Pos(Source,S);
      if I>0 then begin
        s:=Copy(S,1,I-1)+des+Copy(s,I+length(Source),Length(S)-I-length(Source)+1);
        ReplaceStr(s,Source,des);
      end;
    end;
      

  5.   

    在需要的地方是呀Quoted()函数。
      

  6.   

    StringReplace(str,''','"',[rfReplaceAll,rfReplaceAll]);
    全部替换掉。
    字符串S1值为: 
    select * from abc where aa='123' and bb='234' and cc='456' and dd='567' and ee='678'      (全是单引号) 我怎样将上面的值变成 select * from abc where aa=''123'' and bb=''234'' and cc=''456'' and dd=''567'' and ee=''678''      (全变成双引号) 这一句要是在delphi中应该是不是双引号哦,应该是两个单引号才行哦
    AdoQuery1.SQL.Text := select * from abc where aa=''123'' and bb=''234'' and cc=''456'' and dd=''567'' and ee=''678'' ;//里面应该都是单引号哦