DataSet customerOrders = new DataSet();
DataSet.CustomersDataTable customers = new DataSet.CustomersDataTable();
CustomersTableAdapter adapter = new CustomersTableAdapter();
adapter.Fill(customers);
DataSet.OrdersDataTable orders = new DataSet.OrdersDataTable();
OrdersTableAdapter oAdapter = new OrdersTableAdapter();
oAdapter.Fill(orders);
DataRelation relation = (DataRelation)customerOrders.Relations[0];
foreach (DataRow row in customers.Rows)
{
foreach (DataRow orderRow in row.GetChildRows(relation))
{
Response.Write(orderRow["OrderID"].ToString());
}
}
我得到了这个例外:该行不属于与此关系相同的 DataSet。
我究竟做错了什么?