另一个值它显示的EmpID在组合框C#中我如何可以选择每个时间我单击组合框项目
名单我要显示在组合框中EmployeeName但它会得到的EmpID
这里是我的代码
private void EmployeeTimecard_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CSPOSWare.Reports.Properties.Settings.chaplinConnectionString"].ConnectionString))
{
try
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("Select (LastName + ', ' + FirstName) AS Employee, EmpID from Employee ", conn))
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
GrpEmpCBox.Items.Add(rdr["EmpID"].ToString());
}
}
}
catch { }
}
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.GrpEmpCBox.DropDownStyle = ComboBoxStyle.DropDownList;
chkAll.Checked = true;
}
This is where i get the employee name
This is where i want to get the empID from the Employee table
是的,我能做到这一点,但在这里我想要得到的数据表中的记录只有列的EmpID 这是我的问题.. –
好吧,那么你将需要向我们展示了一些表模式和示例数据,以便我们可以看到如何返回员工姓名。 – William