一个最简单的会员登陆代码

2008-02-22 09:27:55来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

是用来新手入门的,高手们不要见笑呀!
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>");
}
}

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:做完一个小网站的一点经验总结(2): asp.net access程序运行环境

下一篇:如何在删除并重新安装 IIS 之后修复 IIS 映射