代码改变世界

asp.net中过滤掉非法字符的方法

2008-12-18 08:30  LvSir  阅读(1931)  评论(0)    收藏  举报

  SqlCommand com = new SqlCommand("select count(*) from loginInfo where Name= @name and Pass=@ps", con);
                com.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 50));
                com.Parameters["@name"].Value = TextName.Text;
                com.Parameters.Add(new SqlParameter("@ps", SqlDbType.VarChar, 50));
                com.Parameters["@ps"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(TextPass.Text, "MD5");

 SqlParameter表示SqlCommand的参数

 

Code