SqlConnection meteor = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["meteor"]);
meteor.Open();//连数据库
SqlCommand comm = new SqlCommand("select * from studentlogin Where
username=('" + TextBox1.Text.ToString().Trim() + "')", meteor);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
{
SqlCommand cmd = new SqlCommand("select count(*) from studentlogin where
password=" + this.TextBox2.Text, meteor);
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.Read())
{
Response.Write("<script language=javascript>alert('登陆成功!')</script>");
Response.Redirect("毕业生.aspx");
}
else
{
Response.Write("<script>alert('密码错误!')</script>");
}
}
else
Response.Write("<script language=javascript>alert('无此用户!')</script>");
dr.Close();
meteor.Close();
怎么改啊?
系统说已经开了DataReader,要先关闭.可关闭了,用户名怎么检查啊 ?