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

减小字体 增大字体 作者:佚名  来源:好再来资源社区  发布时间:2007-03-26 23:26:40
是用来新手入门的,高手们不要见笑呀!
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>");
        }
    }

Tags:

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      0%(0)
  • 差的评价 如果您觉得此文章差,就请您
      0%(0)

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论