BindingSource错误与关系数据集

时间:2013-06-04 19:29:02

标签: c#

我有两个表:客户和订单。我将表填充到数据集,添加与数据集的关系并绑定到数据源:

var customerDs = _customerDAO.ExecuteSelectCommand(_customerCmd.SelectCommand, _customerCmd.TableName);
var orderDs = _orderDAO.ExecuteSelectCommand(_orderCmd.SelectCommand, _orderCmd.TableName);

_ds = new DataSet();

_ds.Tables.Add(customerDs.Tables[0].Copy());
_ds.Tables.Add(orderDs.Tables[0].Copy());

var relation = new DataRelation("CustomerOrderRelation", _ds.Tables["Customer"].Columns["id"],
                            _ds.Tables["CustomerOrder"].Columns["Customer_id"]);
_ds.Relations.Add(relation);

_customerBs = new BindingSource();
_customerBs.DataSource = _ds;
_customerBs.DataMember = "Customer";

_orderBs = new BindingSource();
_orderBs.DataSource = _customerBs;
_customerBs.DataMember = "CustomerOrderRelation";

但错误

  

“无法找到DataMember属性'CustomerOrderRelation'   DataSource“抛出”_customerBs.DataMember =   “CustomerOrderRelation”;“

有什么问题?我无法理解这一点!

0 个答案:

没有答案