Take value from query to label in C#

前端 未结 8 1118
逝去的感伤
逝去的感伤 2021-01-26 12:48

How can i take value from query result to label?

I have two label, one is labelName and one more is labelDepartment

So when i r

8条回答
  •  一生所求
    2021-01-26 13:18

    Check this one - Also set your connection string along with this code

    SQLCommand command = new SQLCommand();
    command.CommandText = " SELECT tbl_staff.staffName,tbl_department.department 
        FROM tbl_staff,tbl_logs,tbl_department 
        WHERE tbl_staff.userID = tbl_logs." + listStaff.SelectedValue + " and tbl_staff.idDepartment = tbl_department.idDepartment ";
    
    SQLDataReader reader = command.executeReader();
    
    while(reader.read())
    {
     labelName.Text = reader.GetString(0);
     labelDepartment.Text = reader.GetString(1);
    }
    

提交回复
热议问题