String start_cd;
String end_cd;
opencon();
SqlCommand res = new SqlCommand("SELECT ID,'" + start_cd + "','" + end_cd + "' FROM Train_route_up WHERE " + start_cd + "!=0 or " + end_cd + "!=0", con);
SqlDataAdapter sda_res = new SqlDataAdapter(res);
DataTable dt_res = new DataTable();
sda_res.Fill(dt_res);
listBox1.DataSource=dt_res;
listBox1.DisplayMember=" +start_cd+ ";
//Train_route_up= SQL table name
//FOT=start_cd value(nvarchar)
listbox show System.Data.DataRowView(mysql table column name = FOR Data type = int)
答案 0 :(得分:1)
尝试
listBox1.DisplayMember= start_cd.Trim();
答案 1 :(得分:0)
如果start_cd
变量包含要显示的列的名称,则将start_cd
变量分配给DisplayMember属性,即
listBox1.DisplayMember = start_cd;