【发布时间】:2016-04-29 09:23:12
【问题描述】:
每次我点击组合框时,它都会显示 EmpID 列表
我想在组合框中显示 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
【问题讨论】:
标签: c# sql sql-server stored-procedures