/// <summary>
/// SQL过滤敏感字符
/// </summary>
/// <param name="InText">要特殊过滤的字符串</param>
/// <returns>过滤后的字符串</returns>
public static string SqlFilterSpecial(string InText)
{
if (InText == "") //如果字符串为空,直接返回。
{
return InText;
}
else
{
InText = InText.Replace("and ", "");
InText = InText.Replace("exec ", "");
InText = InText.Replace("insert ", "");
InText = InText.Replace("select ", "");
InText = InText.Replace("delete ", "");
InText = InText.Replace("update ", "");
InText = InText.Replace(" and", "");
InText = InText.Replace(" exec", "");
InText = InText.Replace(" insert", "");
InText = InText.Replace(" select", "");
InText = InText.Replace(" delete", "");
InText = InText.Replace(" update ", "");
InText = InText.Replace("chr ", "");
InText = InText.Replace("mid ", "");
InText = InText.Replace(" chr", "");
InText = InText.Replace(" mid", "");
InText = InText.Replace("master ", "");
InText = InText.Replace(" master", "");
InText = InText.Replace("or ", "");
InText = InText.Replace(" or", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace("char ", "");
InText = InText.Replace("declare ", "");
InText = InText.Replace("join ", "");
InText = InText.Replace("union ", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace(" char", "");
InText = InText.Replace(" declare", "");
InText = InText.Replace(" join", "");
InText = InText.Replace(" union", "");
InText = InText.Replace("'", "");
InText = InText.Replace("<", "");
InText = InText.Replace(">", "");
InText = InText.Replace("%", "");
InText = InText.Replace("'delete", "");
InText = InText.Replace("''", "");
InText = InText.Replace("\"\"", "");
InText = InText.Replace(",", "");
InText = InText.Replace(">=", "");
InText = InText.Replace("=<", "");
InText = InText.Replace("--", "");
InText = InText.Replace("_", "");
InText = InText.Replace(";", "");
InText = InText.Replace("||", "");
InText = InText.Replace("[", "");
InText = InText.Replace("]", "");
InText = InText.Replace("&", "");
InText = InText.Replace("/", "");
InText = InText.Replace("?", "");
InText = InText.Replace(">?", "");
InText = InText.Replace("?<", "");
InText = InText.Replace(" ", "");
return InText;
}
}
/// SQL过滤敏感字符
/// </summary>
/// <param name="InText">要特殊过滤的字符串</param>
/// <returns>过滤后的字符串</returns>
public static string SqlFilterSpecial(string InText)
{
if (InText == "") //如果字符串为空,直接返回。
{
return InText;
}
else
{
InText = InText.Replace("and ", "");
InText = InText.Replace("exec ", "");
InText = InText.Replace("insert ", "");
InText = InText.Replace("select ", "");
InText = InText.Replace("delete ", "");
InText = InText.Replace("update ", "");
InText = InText.Replace(" and", "");
InText = InText.Replace(" exec", "");
InText = InText.Replace(" insert", "");
InText = InText.Replace(" select", "");
InText = InText.Replace(" delete", "");
InText = InText.Replace(" update ", "");
InText = InText.Replace("chr ", "");
InText = InText.Replace("mid ", "");
InText = InText.Replace(" chr", "");
InText = InText.Replace(" mid", "");
InText = InText.Replace("master ", "");
InText = InText.Replace(" master", "");
InText = InText.Replace("or ", "");
InText = InText.Replace(" or", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace("char ", "");
InText = InText.Replace("declare ", "");
InText = InText.Replace("join ", "");
InText = InText.Replace("union ", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace(" char", "");
InText = InText.Replace(" declare", "");
InText = InText.Replace(" join", "");
InText = InText.Replace(" union", "");
InText = InText.Replace("'", "");
InText = InText.Replace("<", "");
InText = InText.Replace(">", "");
InText = InText.Replace("%", "");
InText = InText.Replace("'delete", "");
InText = InText.Replace("''", "");
InText = InText.Replace("\"\"", "");
InText = InText.Replace(",", "");
InText = InText.Replace(">=", "");
InText = InText.Replace("=<", "");
InText = InText.Replace("--", "");
InText = InText.Replace("_", "");
InText = InText.Replace(";", "");
InText = InText.Replace("||", "");
InText = InText.Replace("[", "");
InText = InText.Replace("]", "");
InText = InText.Replace("&", "");
InText = InText.Replace("/", "");
InText = InText.Replace("?", "");
InText = InText.Replace(">?", "");
InText = InText.Replace("?<", "");
InText = InText.Replace(" ", "");
return InText;
}
}