数据库中的值未在标签中正确显示。如果您使用用户名和密码登录,标签将显示您的全名,studentnumber,course,yearand部分,但我登录的用户名中的全名不匹配。请帮我?
conn.Open();
string sql2 = "SELECT fullname,studentnumber,course,yearandsection FROM students WHERE studentnumber = @studentnumber";
MySqlCommand cmd2 = new MySqlCommand(sql2, conn);
cmd2.Parameters.AddWithValue("@studentnumber", log.txtUsername1.Text);
MySqlDataReader rd2 = cmd2.ExecuteReader();
while(rd2.Read())
{
lblName.Text = rd2["fullname"].ToString();
lblStudNo.Text = rd2["username"].ToString();
lblCourse.Text = rd2["course"].ToString();
lblYrSec.Text = rd2["yearandsection"].ToString();
}
conn.Close();