SQL语义添加含'和"字符的字符串怎样添加到数据库中?

grady.lu 2004-12-07 01:19:03
小弟在将数据添加到数据库的时候(用SQL语句),我用replace将其替换,但在输出的时候又需要转换成原字符,出现错误,代码如下:

Function HTMLencode(str)
dim msg
if str="" then
HTMLencode =""
exit Function
end if
msg = str
msg = replace(msg,chr(39),"\#39") '替换字符'
'msg = replace(msg,chr(34),"\#34") '替换字符"
HTMLencode =msg
End Function
Function Html(str)
dim msg
if str="" then
HTML =""
exit Function
end if
msg = str
'msg = replace(msg,"\#39",chr(39)) ' 还原
'msg = replace(msg,"\#34",chr(34))
Html = msg
End Function
请问高手错在哪,怎么解决?
...全文
82 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lienzhu 2004-12-07
  • 打赏
  • 举报
回复
输入时调用下面函数过滤,输出时不用处理,或用server.htmlencode(str)显示
function checkStr(str)
if isnull(str) then
checkStr = ""
exit function
end if
str = Replace(str, Chr(0), "")
checkStr=replace(str,"'","''")
end function

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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