对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; 
}

记录下

posted on 2014-08-13 21:38  ~紫鱼~  阅读(2665)  评论(0编辑  收藏  举报