对SQL语句进行过滤的函数
/// <summary> /// 过滤SQL非法字符串 /// </summary> /// <param name="value"></param> /// <returns></returns> public static string Filter(string value) { if (string.IsNullOrEmpty(value)) return string.Empty; value = Regex.Replace(value, @";", string.Empty); value = Regex.Replace(value, @"'", string.Empty); value = Regex.Replace(value, @"&", string.Empty); value = Regex.Replace(value, @"%20", string.Empty); value = Regex.Replace(value, @"--", string.Empty); value = Regex.Replace(value, @"==", string.Empty); value = Regex.Replace(value, @"<", string.Empty); value = Regex.Replace(value, @">", string.Empty); value = Regex.Replace(value, @"%", string.Empty); return value; }
记录下