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();