combobox的错误:无法绑定到新的显示成员!急!请进~
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string ConStr = "Data Source=localhost;Integrated Security=SSPI;" +
"Initial Catalog=fcfn";
string Sql = "select zyname from zydm where cc=" + "'" + comboBox1.Text + "'";
SqlConnection SqlConn = new SqlConnection(ConStr);
SqlConn.Open();
SqlDataAdapter da = new SqlDataAdapter(Sql, SqlConn);
DataSet ds = new DataSet();
da.Fill(ds, "zydm");
DataTable dt = ds.Tables["zydm"];
comboBox2.DataSource = dt;
comboBox2.DisplayMember = comboBox1.Text;
comboBox2.ValueMember = comboBox1.Text;
SqlConn.Close();
}
以上是我的代码,麻烦各位帮忙为什么会出现如题的错误!谢谢!
------解决方案--------------------
SqlDataAdapter da = new SqlDataAdapter(Sql, SqlConn);
DataSet ds = new DataSet();
da.Fill(ds,"zydm");
comboBox2.DataSource = ds.Tables[0];
comboBox2.DisplayMember = "zydm";
comboBox2.ValueMember = "zyname";
SqlConn.Close();
这个 你看看 我的能行