如何把有特殊字符“&”或HTML代码保存到Access数据库中?
如题:
如何把有特殊字符“&”或HTML代码保存到Access数据库中?field_3="<label><font>Next Generation</font> Management Consultants</label>"
field_4="Copyright © 2005-2010BusinessOperationsandTechnologyLtd.Allrightsreserved"
sql="update [config] set companyDescript='"&Server.HTMLEncode(checkStr(trim(request.form("field_3"))))&"',copyRight='"&Server.HTMLEncode(checkStr(trim(request.form("field_14"))))&"' where languages='"&languages&"'"
conn.execute(sql)
执行后查看数据库
copyRight的值为“Copyright ”,后面的“© 2005-2010BusinessOperationsandTechnologyLtd.Allrightsreserved"都没有了。
而
companyDescript的值则把所有的< 和 > 替换成 < >
怎样才能正确保存呢?
------解决方案--------------------
VBScript code
field_3 = Trim(request.form("field_3"))
field_14 = Trim(request.form("field_14"))
sql = "update [config] set companyDescript='" & Replace(field_3, "'", "''") & "',copyRight='" & Replace(field_14, "'", "''") & "' where languages='" & languages & "'"
conn.execute(sql)