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

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


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;
        }



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


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。