这是我做的一个登陆的代码,不管用户名和密码是正确还是错误都提示登陆失败。cont为-1哪位帮忙解决一下 if (Request.HttpMethod=="POST") { string name = Request.Form["textfield"].ToString(); string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Request.Form["textfield2"].ToString(),"MD5"); string sql = "select * from user where user_account='"+name+"' and user_pwd='"+pwd+"'"; string str = "server=localhost;user id=root;database=tfdo;password=97381687"; MySqlConnection mycoon = new MySqlConnection(str); MySqlCommand mycom = new MySqlCommand(sql,mycoon); mycoon.Open(); int cont =Convert.ToInt32(mycom.ExecuteNonQuery()); if (cont>0) { Session["user_account"] = Request.Form["textfield"].ToString(); mycoon.Close(); Response.Write("<script>alert('登錄成功');location='mina.aspx'</script>");