string conn = "server=.;database=login;user id=sa;pwd=123";
SqlConnection cn = new SqlConnection(conn);
cn.Open();
string strsql = "select user_name,user_pwd from admin where user_name='" + TextBox1.Text + "' or user_pwd='" + TextBox2.Text + "'";
SqlCommand cmd = new SqlCommand(strsql, cn);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
if (rd.GetValue(0).ToString() == TextBox1.Text)
{
if (rd.GetValue(1).ToString() == TextBox2.Text)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('密码错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户不存在!')</script>");
}
}<
2008-9-16 at 19:32
2008-9-17 at 10:45
2008-10-3 at 14:46
2008-10-5 at 4:25
2008-10-21 at 9:32
2008-12-1 at 14:06
2008-12-11 at 11:28
2008-12-17 at 11:21
2008-12-22 at 12:15
2008-12-24 at 22:21
2009-1-13 at 23:25
2010-4-1 at 0:20