刚学!问的问题比较弱!不要骂!^_^这样写验证对么!我这怎么用户名与密码对不对都通过了呢!count返回的是1 string AdminId=this.txtId.Text;
string AdminPwd=this.txtPwd.Text;
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["con"]);
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from Admin where AdminId='"+AdminId+"'and AdminPwd='"+AdminPwd+"'",con);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count<0)
{
Response.Write("<script>alert('用户名或密码不对!');</script>");
Response.Redirect("Login.aspx");
}
else
{
Session["falg"]="admin";
Response.Redirect("index.aspx");