SqlHelper.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public static class SqlHelper
{
    /// <summary>
    /// 替换SQL特殊字符
    /// </summary>
    /// <param name="obj">需序转化的对象</param>
    /// <returns></returns>
    public static string ToMSSQL(this String obj)
    {
        return obj.Replace("'", "''").Replace("[", "[[]").Replace("%", "[%]").Replace("_", "[_]");
    }
}
View Code

相关文章:

  • 2022-01-25
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2022-01-20
  • 2022-12-23
  • 2021-07-17
相关资源
相似解决方案