我想问一下插入查询结果的方法如下:
哪个ID是cusomter ID,num是购买的商品数量,Product_x是产品的ID
ID num_0 Product_0 num_1 Product_1 num_2 Product_2
1 3 435 2 122 1 236
1 324 232
1 236
2 2 345 3 253 0
2 1519 1563
2 79
以下是我的以下代码
foreach (DataRow dr in tableShowDate.Rows)
{
String wo_number = handle(dr["ID"].ToString()) ;
String date = handle(dr["DATE"].ToString());
DataRow[] tempRowSelected = tempTable.Select("ID like '" + wo_number + "' ");
DataRow [] originalRowSelected = tableOriginal.Select("ID like '" + wo_number + "' " + " and"+ " DATE = '" + date + "' " , "PRODUCT_ID ASC");
for (int t = 0; t < tableOriginal.Rows.Count; t++)
{
for (int x = 1; x < tempTable.Columns.Count; x++)
{
String compareDate = handle(tableOriginal.Rows[t]["CREATE_DATE"].ToString());
if (compareDate == Days[x - 1])
{
tempRow["PHOTO_" + x.ToString()] = Convert.ToInt32(tableOriginal.Rows[t]["NUM"]);
for (int s = 0; s < originalRowSelected.Length; s++)
{
tempRow["ID_" + x.ToString()] = httpLink + Convert.ToString(tableOriginal.Rows[t]["Product_ID"]);
break;
}
}
}
}
}
我想问一下如何插入表中所示的行,因为我已经完成了DataTable.select
以下是我的表
Customer_ID num Product_ID Date
1 3 435 2012-3-4
1 3 324 2012-3-4
1 3 236 2012-3-4
1 2 122 2012-3-5
1 2 232 2012-3-5
1 1 236 2012-3-6
2 2 345 2012-3-4
2 2 1519 2012-3-4
2 3 253 2012-3-5
2 3 1563 2012-3-5
2 3 79 2012-3-5