ASP.NET节能特殊字符数据库 [英] ASP.NET-Saving Special Characters to Database

查看:494
本文介绍了ASP.NET节能特殊字符数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何能节省字符串特殊字符DB.Special字符可能contatin单个引号/双引号等。我使用ASP.NET与C#

Please tell me how can save a string with special characters to DB.Special characters may contatin single quotes/double quotes etc.. I am using ASP.NET with C#

推荐答案

使用参数化查询。

http://aspnet101.com/aspnet101/tutorials.aspx?id=1

当显示到客户端,你也应该用Server.HtmlEn code()转换成具有特殊的意义在HTML中数字字符引用的字符。

When rendering to the client, you should also use Server.HtmlEncode() to convert characters which have special meaning in HTML to numeric character references.

这篇关于ASP.NET节能特殊字符数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆