|
C#中连接DataTable的方法(3)
table.BeginLoadData();
foreach(DataRow firstrow in ds.Tables[0].Rows)
{
//得到行的数据
DataRow[] childrows = firstrow.GetChildRows(r);
if(childrows != null && childrows.Length > 0)
{
object[] parentarray = firstrow.ItemArray;
foreach(DataRow secondrow in childrows)
{
object[] secondarray = secondrow.ItemArray;
object[] joinarray = new object[parentarray.Length+secondarray.Length];
Array.Copy(parentarray,0,joinarray,0,parentarray.Length);
Array.Copy(secondarray,0,joinarray,parentarray.Length,secondarray.Length);
table.LoadDataRow(joinarray,true);
}
}
}
table.EndLoadData();
}
|