我有两个表:客户和订单。我将表格填充到数据集,添加与数据集的关系并绑定到数据源:
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";
但是错误
“在“_customerBs.DataMember = “CustomerOrderRelation”上抛出的“DataMember 属性 'CustomerOrderRelation' 在 DataSource 上找不到”;”
什么问题?我想不通!