delphi 单引号在字符串中使用方法

可以看delph的帮助,里面有这个问题详细说明:
A character string, also called a string literal or string constant, consists of a quoted string, a control string, or a combination of quoted and control strings. Separators can occur only within quoted strings.

A quoted string is a sequence of up to 255 characters from the extended ASCII character set, written on one line and enclosed by apostrophes. A quoted string with nothing between the apostrophes is a null string. Two sequential apostrophes in a quoted string denote a single character, namely an apostrophe. For example,

'BORLAND'           { BORLAND }  //字符
'You''ll see'       { You'll see }     //两个'连接在一起代表字符中的一个'号.
''''                { ' }   同上.
''                  { null string }  //空值
' '                 { a space }       //一个空格

 

示例:
SQL语句:  where usename like '%张三%'
str1 :='where ' + FieldName + ' like ' + '''%' + SearchBuffer + '%'''       

 

你可能感兴趣的:(Delphi)