首页 > 数据库技术 > 详细

sql 查询条件过滤替换特许符号(‘,",+,!等)

时间:2015-01-27 07:07:11      阅读:268      评论:0      收藏:0      [点我收藏+]

查询条件过滤替换特许符号


public static string SpecialSymbols(string strText)
        {
            strText = strText.Trim();
            strText = strText.Replace("!", "‘ + char(33) + ‘");
            strText = strText.Replace("\"", "‘ + char(34) + ‘");
            strText = strText.Replace("$", "‘ + char(36) + ‘");
            strText = strText.Replace("%", "‘ + char(37) + ‘");
            strText = strText.Replace("&", "‘ + char(37) + ‘");
            strText = strText.Replace("‘", "‘ + char(39) + ‘");
            strText = strText.Replace("(", "‘ + char(40) + ‘");
            strText = strText.Replace(")", "‘ + char(41) + ‘");
            strText = strText.Replace("*", "‘ + char(42) + ‘");
            strText = strText.Replace("+", "‘ + char(43) + ‘");
            strText = strText.Replace(",", "‘ + char(44) + ‘");
            strText = strText.Replace("-", "‘ + char(45) + ‘");
            strText = strText.Replace(".", "‘ + char(46) + ‘");
            strText = strText.Replace("/", "‘ + char(47) + ‘");
            strText = strText.Replace("", "‘ + char(47) + ‘");
            return strText;
        }



可继续补充或者优化,未测试。


sql 查询条件过滤替换特许符号(‘,",+,!等)

原文:http://my.oschina.net/TOW/blog/372012

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!