【发布时间】:2014-04-24 12:22:22
【问题描述】:
我正在尝试按照上述方式将两个DataSet.tables 合并到一张表中。我想知道是否可以这样做。我调用我的存储过程,它返回我将它们设置到表中的值。 (如下图所示)。
试过了:
在映射部分添加两个表名("Tables", IncomingProductTotals)。
将两者作为一个表添加到映射部分("Tables", IncomingProductTotals1)("Tables", TotalDownTimeResults1)
我能找到的大量研究是关于 sql 连接表。
SqlCommand cmd = new SqlCommand("L_GetTimeTotals", conn);
cmd.Parameters.Add("@startTime", SqlDbType.DateTime, 30).Value = RadDateTimePicker2.SelectedDate;
cmd.Parameters.Add("@endTime", SqlDbType.DateTime, 30).Value = RadDateTimePicker3.SelectedDate;
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
var ds = new DataSet();
ds.Tables.Add("IncomingProductTotals");
ds.Tables.Add("IncomingProductTotalsA");
ds.Tables.Add("IncomingProductTotalsB");
ds.Tables.Add("IncomingProductTotals1");
ds.Tables.Add("IncomingProductTotalsA1");
ds.Tables.Add("IncomingProductTotalsB1");
da.TableMappings.Add("Table", "IncomingProductTotals");
da.TableMappings.Add("Table1", "IncomingProductTotalsA");
da.TableMappings.Add("Table2", "IncomingProductTotalsB");
da.TableMappings.Add("Table3", "IncomingProductTotals1");
da.TableMappings.Add("Table4", "IncomingProductTotalsA1");
da.TableMappings.Add("Table5", "IncomingProductTotalsB1");
da.Fill(ds);
ds.Tables.Remove("IncomingProductTotalsA");
ds.Tables.Remove("IncomingProductTotalsB");
ds.Tables.Remove("IncomingProductTotalsA1");
ds.Tables.Remove("IncomingProductTotalsB1");
ExcelHelper.ToExcel(ds, "TimeTotals.xls", Page.Response);
【问题讨论】: