1. /// <summary>
  2. /// SQL like 语句特殊字符 替换
  3. /// </summary>
  4. /// <returns></returns>
  5. public static string SQLStrReplace(string str)
  6. {
  7. String RetuenValue = "";
  8. if (str.Trim() != "")
  9. {
  10. RetuenValue = str.Replace("[", "[[]").Replace("\'", "\'\'").Replace("^", "[^]").Replace("--", "[--]").Replace("_", "[_]").Replace("%", "[%]").Replace(@"\", "\\\\");
  11. }
  12. return RetuenValue;
  13. }

 

版权声明:本文为kongdf原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/kongdf/archive/2012/06/27/2566480.html