另一個值它顯示的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