DataTable_A:
物料号 数量
MAT_01 111
MAT_02 222
MAT_03 333
...DataTable_B:
物料号 物料名称
MAT_01 MAT_01名称
MAT_02 MAT_02名称
MAT_03 MAT_03名称
...想通过DataTable_A+DataTable_B,得到以下结果(赋值给DataTable_C)
物料号 数量 物料名称
MAT_01 111 MAT_01名称
MAT_02 222 MAT_02名称
MAT_03 333 MAT_03名称
...
请问怎么实现?
物料号 数量
MAT_01 111
MAT_02 222
MAT_03 333
...DataTable_B:
物料号 物料名称
MAT_01 MAT_01名称
MAT_02 MAT_02名称
MAT_03 MAT_03名称
...想通过DataTable_A+DataTable_B,得到以下结果(赋值给DataTable_C)
物料号 数量 物料名称
MAT_01 111 MAT_01名称
MAT_02 222 MAT_02名称
MAT_03 333 MAT_03名称
...
请问怎么实现?
Dim RowCtr As Integer
' Dim an array of datarows to hold the child records.
Dim drarray() As DataRow
' GetChildRows gets related rows. It is a method on the datatable, and
' takes a DataRelation name as a string.
RowCtr = 0
drarray = dsCustomersOrders1.Customers(RowCtr).GetChildRows("CustomersOrders")// C#
int rowCtr;
// Declare an array of datarows to hold the child records.
DataRow[] drarray;
// GetChildRows gets related rows. It is a method on the datatable, and
// takes either DataRelation object name as a string.
rowCtr = 0;
drarray = dsCustomersOrders1.Customers[rowCtr].GetChildRows("CustomersOrders");
同样,可以通过调用子表中数据行的 GetParentRow 方法获取给定子记录的父行。这种情况下,该方法不返回数组,而是返回单个数据行。有关更多信息,请参见导航表间关系。
增加一个动态表,增加三列
前面省略。。
DataTable dt = new DataTable();
dt.Columns.Add["物料号"]
dt.Columns.Add["数量"]
dt.Columns.Add["物料名称"]
for(int i=0;i<dt.row.count;i++)
{
dt.Rows[i]["数量"] = "需要的值";
...
..}
注:DataTable_A,DataTable_B 在同一个DATASET 里.因我看书上说,DATASET = 数据库,DataTable = 数据表.所以想看看有没有这种方法.