gpt4 book ai didi

c# - 无法绑定(bind)多部分标识符 "System.Data.DataRowView"

转载 作者:行者123 更新时间:2023-11-30 17:05:51 24 4
gpt4 key购买 nike

<分区>

我有一个填充 Combobox1 的表,而 Combobox1 应该填充 Combobox2,这就是问题所在。这是我得到的异常(exception)

The multi-part identifier "System.Data.DataRowView" could not be bound.

代码:

    private void frm2_Load(object sender, EventArgs e)
{
//Populate Combobox1
SqlDataAdapter da = new SqlDataAdapter("SELECT CategoryID, Name FROM Categories", clsMain.con);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox1.DataSource = ds.Tables[0];
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "CategoryID";
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//populate Combobox2
SqlDataAdapter da = new SqlDataAdapter("SELECT SubCategoryID, Name FROM SubCategories WHERE CategoryID=" + comboBox1.SelectedValue, clsMain.con);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox2.DataSource = ds.Tables[0];
comboBox2.DisplayMember = "Name";
comboBox2.ValueMember = "SubCategoryID";
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com