select ID from Table1 where Name = '" & name & "'" but, some names 里面有"'", 所以会出错. 怎么办? 谢谢.
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 里面有"'", 所以会出错. : 怎么办? 谢谢.
W*S
3 楼
use " instead
【在 s***u 的大作中提到】 : select ID from Table1 where Name = '" & name & "'" : but, some names 里面有"'", 所以会出错. : 怎么办? 谢谢.
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.
s*u
5 楼
How to instead ya? thanks.
【在 W****S 的大作中提到】 : use " instead
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?
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?
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 "''"