asp.net 连接数据库
密码总是不匹配!
代码:
SqlCommand cmd = new SqlCommand("select * from [login] where username='"+TextBox1.Text+"'",conn);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
if (sdr["password"].ToString() ==TextBox2.Text)
{
Response.Redirect("hello.aspx");
}
else
{
Response.Write("<script language=javascript >alert('密码错误!')</script>");
}
}
else
{
Response.Write("<script language=javascript >alert('用户名错误或不存在!')</script>");
}
------解决方案--------------------
楼主发错地方了,赶快结贴发到asp论坛区吧