delphi中字符串中如何输入单引号?

stephen722 2006-03-29 12:39:45
delphi中字符串中如何输入单引号?
例如: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+%
...全文
3205 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xeonfeng 2006-04-25
  • 打赏
  • 举报
回复
经测试用3个单引号'''代替一个引号'是可行的
nojave 2006-04-10
  • 打赏
  • 举报
回复
两单引=SQL解析的一单引
rowa11 2006-04-09
  • 打赏
  • 举报
回复
可以看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 }
lxjssy 2006-04-09
  • 打赏
  • 举报
回复
示例:

str1 :='where ' + FieldName + ' like ' + '''' + '%' + SearchBuffer + '%'+ ''''
ahjoe 2006-04-06
  • 打赏
  • 举报
回复
楼上的,别乱说 。

两个单引号,在串中代表一个单引号。
hzbhzb 2006-04-05
  • 打赏
  • 举报
回复
用双引号即可
xiaoxinghappy 2006-04-03
  • 打赏
  • 举报
回复
在DELPHI的字符串里面,两个单引号表示为一个单引号,所以只要在字符串的有单引号的地方写两个单引号就可以了,就好C里面的用两“\\”表示一个“\”一样,VB里也是类似的用来用双引号表示一下双引号
cwwa 2006-04-02
  • 打赏
  • 举报
回复
要是嫌引号多了容易乱就用#39替换单引号,
如sql为select * from table where id='1'
在delphi里为'select * from table where id='+#39+'1'+#39
seeder 2006-03-31
  • 打赏
  • 举报
回复
'''三个单引号
pongjun64 2006-03-31
  • 打赏
  • 举报
回复
标准的sql语句是这样的:select * from temp where name like'a%'
delphi:str1:='select * from temp where name like'+''''+edit1.text+%+'''';
llh6795 2006-03-30
  • 打赏
  • 举报
回复
在程序代码里,用单引号 引起来的两个单引号,经过编译后是一个单引号。
'''ok''':编译后表示'ok';
cuteant 2006-03-29
  • 打赏
  • 举报
回复
str:='abcde''fghi' ;
caixinke 2006-03-29
  • 打赏
  • 举报
回复 1
我一直也不会用这个东西,反正我是用笨把法处理的,是麻烦了点,但还能用

举例:aql.add('select * from tablename where username='+quotedstr('张三'));

16,743

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧