Delphi QuotedStr函数
Delphi QuotedStr函数-给字符串两边加单引号并返回.
Quoted 英文意思:引用、转引
函数原型:
?
|
1 2 3 4 5 6 7 8 9
|
function QuotedStr(const S: string): string;var I: Integer;begin Result := S; for I := Length(Result) downto 1 do if Result[I] = '''' then Insert('''', Result, I); Result := '''' + Result + '''';end; |
函数作用:给字符串两边加单引号并返回.
例如 (SQL语句):
?
|
1 2 3 4
|
//ss 字符串'select * from AA where Str1='''+ ss +''' ' ;//等同于:'select * from AA where Str1='+ QuotedStr(ss)+' ' ; |
赞 (0)
