avatar
这句SQL怎么写?# Database - 数据库
s*u
1
select ID from Table1 where Name = '" & name & "'"
but, some names 里面有"'", 所以会出错.
怎么办? 谢谢.
avatar
q*e
2
if it is in code, then it is easy since you can set a string
for it. if you use it in command line, then it may be
impossible.

【在 s***u 的大作中提到】
: select ID from Table1 where Name = '" & name & "'"
: but, some names 里面有"'", 所以会出错.
: 怎么办? 谢谢.

avatar
W*S
3
use " instead

【在 s***u 的大作中提到】
: select ID from Table1 where Name = '" & name & "'"
: but, some names 里面有"'", 所以会出错.
: 怎么办? 谢谢.

avatar
s*u
4
the name is from :
name = recordset1("Name")
so, impossible?

【在 q***e 的大作中提到】
: if it is in code, then it is easy since you can set a string
: for it. if you use it in command line, then it may be
: impossible.

avatar
s*u
5
How to instead ya?
thanks.

【在 W****S 的大作中提到】
: use " instead
avatar
a*o
6
best way is to write a stored procedure and take this
parameter.
the simplest way is to replace the "'" with "''"

【在 s***u 的大作中提到】
: the name is from :
: name = recordset1("Name")
: so, impossible?

avatar
g*p
7

Add this line after the above:
name=replace(recordset("Name"),"'","''")
What it does is, it escapes the ' character so your value
indeed can contain apostrophe.
For details see:
http://www.aspfaq.com/faq/faqShow.asp?fid=4
HTH.

【在 s***u 的大作中提到】
: the name is from :
: name = recordset1("Name")
: so, impossible?

avatar
s*n
8
for vb, asp: select ID from Table1 where Name = '" & Replace(name,"'","'') &
"'"

【在 a****o 的大作中提到】
: best way is to write a stored procedure and take this
: parameter.
: the simplest way is to replace the "'" with "''"

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。