| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 836 人关注过本帖
标题:为什么老是显示登录失败?
取消只看楼主 加入收藏
fylnlx
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2009-3-15
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
为什么老是显示登录失败?
protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = WebConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            conn.Open();
            SqlCommand cmd = new SqlCommand("select [name],password from te", conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds,"te");
            SqlDataReader dr = cmd.ExecuteReader();
            string name = Convert.ToString(dr);
            dr.Close();
            SqlDataReader dr1 = cmd.ExecuteReader();
            string password = Convert.ToString(dr1);
            Response.Write(name);
            if(txtName.Text.ToString()==name&&txtPassword.Text.ToString()==password)
            {
                Response.Write("登录成功");
            }
            else
            {
                Response.Write("登录失败");
            }
            dr1.Close();
            conn.Close();
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtName.Text = "";
            this.txtPassword.Text = "";
        }
    }
搜索更多相关主题的帖子: 失败 登录 
2009-09-01 22:39
快速回复:为什么老是显示登录失败?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011504 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved