注册 登录
编程论坛 ASP.NET技术论坛

如何实现用ID号登录,登录后显示用户名?

andriysmith 发布于 2008-05-27 18:27, 1015 次点击
请问哪位高手可以教一教我.....急用!
SqlCommand scd = new SqlCommand("select count(*) from SysUser where U_ID='" + this.UID.Text.ToString() + "' and U_PSW='" + this.Userpwd.Text.ToString() + "'", sqlcon);
        int count = Convert.ToInt32(scd.ExecuteScalar());
        if (count > 0)
        {
            Session["U_ID"] = this.UID.Text.ToString();
            this.Panel2.Visible = true;
            this.Panel1.Visible = false;
            this.Label1.Text = Session["U_ID"].ToString();
        }
        else
        {
            Response.Write(this.message("编号或者密码错误"));
        }
4 回复
#2
hebingbing2008-05-27 21:06
上面的程序不是可以完成你要的功能吗?
#3
petroe2008-05-27 22:22
SqlCommand scd = new SqlCommand("select count(*) from SysUser where U_ID='" + this.UID.Text.ToString() + "' and U_PSW='" + this.Userpwd.Text.ToString() + "'", sqlcon);

数据库查询语言写错了,你的那种是返回记录总数
应该这样写,
SqlCommand scd = new SqlCommand("select * from SysUser where U_ID='" + this.UID.Text.ToString() + "' and U_PSW='" + this.Userpwd.Text.ToString() + "'", sqlcon);

然后用 datereader 读出来。建议LZ多看点基础。
#4
andriysmith2008-05-27 23:27
这是显示ID号,不显示用户名
#5
cyyu_ryh2008-05-28 10:34
有没用户名这个字段哦?
1