我正在尝试输入listitem值结果的选择查询代码,但是我收到了这个错误:
无效的列名称' adam'。
我不知道代码有什么问题。
这是代码:
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
label11.Text = "";
t1.Text = "";
t2.Text = "";
t3.Text = "";
t4.Text = "";
t5.Text = "";
t6.Text = "";
t7.Text = "";
t8.Text = "";
cb2.Text = "";
pb1.Image = null;
con.Open();
String sqlselectquery = "select * from employee where emp_id=" + listBox1.SelectedValue;
SqlCommand cmd = new SqlCommand(sqlselectquery, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
t1.Text = (dr["emp_id"].ToString());
t2.Text = (dr["emp_name"].ToString());
t3.Text = (dr["emp_birth"].ToString());
t4.Text = (dr["emp_id_code"].ToString());
t5.Text = (dr["emp_add"].ToString());
t6.Text = (dr["education"].ToString());
t7.Text = (dr["hiredate"].ToString());
t8.Text = (dr["salary"].ToString());
cb1.SelectedValue = (dr["job_id"].ToString());
cb2.Text = (dr["emp_rel"].ToString());
byte[] img = (byte[])(dr["emp_pic"]);
MemoryStream ms = new MemoryStream(img);
pb1.Image = Image.FromStream(ms);
}
con.Close();
}