SQL like 语句特殊字符 替换

   /// <summary>
    /// SQL like 语句特殊字符 替换
    /// </summary>
    /// <returns></returns>
    public static string SQLStrReplace(string str)
    {
        String RetuenValue = "";
        if (str.Trim() != "")
        {
            RetuenValue = str.Replace("[", "[[]").Replace("'", "''").Replace("^", "[^]").Replace("--", "[--]").Replace("_", "[_]").Replace("%", "[%]").Replace(@"\", "\\\\");
        }
        return RetuenValue;
    }

 

posted @ 2012-06-27 22:58  kiddy-star  阅读(486)  评论(0编辑  收藏  举报