private string getInQuerySql(string query)
{
string resulr = "";
foreach (var item in query.Split(','))
{
resulr += LibSysUtils.QuoteStr(item);
resulr += ",";
}
return resulr.TrimEnd(',');
}

 

/// <summary>
/// SQL替换单引号,防止注入
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string QuoteStr(string value)
{
if (string.IsNullOrEmpty(value))
return "''";

value = value.Replace("'", "''");
return string.Format("'{0}'", value);
}

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-12-22
  • 2021-06-27
  • 2022-02-08
  • 2021-05-07
猜你喜欢
  • 2022-12-23
  • 2021-07-14
  • 2021-12-05
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案