标题:C#Winform如何获取登录时输入的用户名
取消只看楼主
初学者6
Rank: 2
等 级:论坛游民
帖 子:34
专家分:20
注 册:2016-12-30
结帖率:66.67%
 问题点数:0 回复次数:1 
C#Winform如何获取登录时输入的用户名
我在登录页面获取了:UserHelper.loginId = txtLoginId.Text;
                    UserHelper.loginPwd = txtLoginPwd.Text;

但是加断点调试时看到的值是空值,这是怎么回事?
这是应该显示用户信息的页面!
            txtLogId.Text = UserHelper.loginId;
            txtpwd.Text = UserHelper.loginPwd;

            string constr = "Server=.;DataBase=MySchool;Uid=sa;Pwd=yule9616866@;Integrated Security=true";
            SqlConnection con = new SqlConnection(constr);
            con.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
             = CommandType.Text;
             = "select LoginPwd,UserStateId,TeacherName,Sex,Birthday from Teacher where LoginId = '" + txtLogId.Text  + "'and LoginPwd='"+txtpwd .Text+"'";
            SqlDataReader dr = cmd.ExecuteReader();

            dr.Read();
            txtLogId.Text = dr["LoginId"].ToString();
            txtpwd.Text = dr["LoginPwd"].ToString();
            txtSpwd.Text = "";
            cmbLogState.Text = dr["UserStateId"].ToString();
            txtLogName.Text = dr["TeacherName"].ToString();
            txtLogSex.Text = dr["Sex"].ToString();
            dateTimePicker1.Text = dr["Birthday"].ToString();
搜索更多相关主题的帖子: 获取 登录 Text cmd ToString 
2019-05-02 16:36
初学者6
Rank: 2
等 级:论坛游民
帖 子:34
专家分:20
注 册:2016-12-30
得分:0 
是不同窗体的登录名(我有两个登录页面)!
2019-05-07 12:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494510-1-1.html




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

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