gpt4 book ai didi

c# - 数据源错误 : "Cannot Bind to property or Column"

转载 作者:太空狗 更新时间:2023-10-29 18:13:34 25 4
gpt4 key购买 nike

我正在使用 C# 处理数据库,当我点击显示按钮时出现错误:

Error:
Cannot bind to the property or column LastName on the DataSource. Parameter name: dataMember

代码:

private void Display_Click(object sender, EventArgs e)
{
Program.da2.SelectCommand = new SqlCommand("Select * From Customer", Program.cs);
Program.ds2.Clear();
Program.da2.Fill(Program.ds2);
customerDG.DataSource = Program.ds2.Tables[0];

Program.tblNamesBS2.DataSource = Program.ds.Tables[0];

customerfirstname.DataBindings.Add(new Binding("Text", Program.tblNamesBS2, "FirstName"));
customerlastname.DataBindings.Add(new Binding("Text", Program.tblNamesBS2, "LastName")); //Line Error occurs on.
}

不确定这意味着什么,任何人都可以提供帮助,如果我注释掉最后两行,它将正确显示。

最佳答案

如果绑定(bind)到 NULL 对象,您也会遇到此错误。

关于c# - 数据源错误 : "Cannot Bind to property or Column",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11645551/

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