0
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。該行不屬於與此關係相同的數據集
我在做什麼錯?
我有一個疑問,改變的代碼
這個片段。 'foreach(DataRow orderRow in row.GetChildRows(relation))'的目的是什麼? –