C#防止sql注入 (转)

来源:互联网 发布:iphone连接mac传照片 编辑:程序博客网 时间:2024/05/21 06:26
C#防止sql注入
publicclass SqlZr
{
     public SqlZr()
     {
         //
         // TODO: 在此处添加构造函数逻辑
         //
     }
    publicstatic string DelSQLStr(string str)
    {
        if (str ==null || str == "")
            return "";
        str = str.Replace(";","");
        str = str.Replace("'","");
        str = str.Replace("&","");
        str = str.Replace("%20","");
        str = str.Replace("--","");
        str = str.Replace("==","");
        str = str.Replace("<","");
        str = str.Replace(">","");
        str = str.Replace("%","");
        str = str.Replace("+","");
        str = str.Replace("-","");
        str = str.Replace("=","");
        str = str.Replace(",","");
        return str;
    }
}
0 0
原创粉丝点击