例如:str,str1:string;
str:='abcde'fghi' ; e'f中间的单引号该如何输入,用\'是不行的!
我把edit1.text传递到sql语句里不知道该如何写.
标准的sql语句是这样的:select * from temp where name like'a%'
delphi该如何写啊?str1:='select * from temp where name like'+edit1.text+%
13 个解决方案
#1
str:='abcde''fghi' ;
#2
我一直也不会用这个东西,反正我是用笨把法处理的,是麻烦了点,但还能用
举例:aql.add('select * from tablename where username='+quotedstr('张三'));
举例:aql.add('select * from tablename where username='+quotedstr('张三'));
#3
在程序代码里,用单引号 引起来的两个单引号,经过编译后是一个单引号。
'''ok''':编译后表示'ok';
'''ok''':编译后表示'ok';
#4
标准的sql语句是这样的:select * from temp where name like'a%'
delphi:str1:='select * from temp where name like'+''''+edit1.text+%+'''';
delphi:str1:='select * from temp where name like'+''''+edit1.text+%+'''';
#5
'''三个单引号
#6
要是嫌引号多了容易乱就用#39替换单引号,
如sql为select * from table where id='1'
在delphi里为'select * from table where id='+#39+'1'+#39
如sql为select * from table where id='1'
在delphi里为'select * from table where id='+#39+'1'+#39
#7
在DELPHI的字符串里面,两个单引号表示为一个单引号,所以只要在字符串的有单引号的地方写两个单引号就可以了,就好C里面的用两“\\”表示一个“\”一样,VB里也是类似的用来用双引号表示一下双引号
#8
用双引号即可
#9
楼上的,别乱说 。
两个单引号,在串中代表一个单引号。
两个单引号,在串中代表一个单引号。
#10
可以看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 }
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 }
#11
示例:
str1 :='where ' + FieldName + ' like ' + '''' + '%' + SearchBuffer + '%'+ ''''
str1 :='where ' + FieldName + ' like ' + '''' + '%' + SearchBuffer + '%'+ ''''
#12
两单引=SQL解析的一单引
#13
经测试用3个单引号'''代替一个引号'是可行的
#1
str:='abcde''fghi' ;
#2
我一直也不会用这个东西,反正我是用笨把法处理的,是麻烦了点,但还能用
举例:aql.add('select * from tablename where username='+quotedstr('张三'));
举例:aql.add('select * from tablename where username='+quotedstr('张三'));
#3
在程序代码里,用单引号 引起来的两个单引号,经过编译后是一个单引号。
'''ok''':编译后表示'ok';
'''ok''':编译后表示'ok';
#4
标准的sql语句是这样的:select * from temp where name like'a%'
delphi:str1:='select * from temp where name like'+''''+edit1.text+%+'''';
delphi:str1:='select * from temp where name like'+''''+edit1.text+%+'''';
#5
'''三个单引号
#6
要是嫌引号多了容易乱就用#39替换单引号,
如sql为select * from table where id='1'
在delphi里为'select * from table where id='+#39+'1'+#39
如sql为select * from table where id='1'
在delphi里为'select * from table where id='+#39+'1'+#39
#7
在DELPHI的字符串里面,两个单引号表示为一个单引号,所以只要在字符串的有单引号的地方写两个单引号就可以了,就好C里面的用两“\\”表示一个“\”一样,VB里也是类似的用来用双引号表示一下双引号
#8
用双引号即可
#9
楼上的,别乱说 。
两个单引号,在串中代表一个单引号。
两个单引号,在串中代表一个单引号。
#10
可以看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 }
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 }
#11
示例:
str1 :='where ' + FieldName + ' like ' + '''' + '%' + SearchBuffer + '%'+ ''''
str1 :='where ' + FieldName + ' like ' + '''' + '%' + SearchBuffer + '%'+ ''''
#12
两单引=SQL解析的一单引
#13
经测试用3个单引号'''代替一个引号'是可行的