C# 连接两个不同表中的列并使用索引的数据集
我相信我的datatable需要在最后一条语句中循环,以提取两个datatable并将它们组合起来 我的问题是,我对所有这些都是新手,我对数据集有一些简单的了解,但我还没有一点线索将它们连接起来C# 连接两个不同表中的列并使用索引的数据集,c#,asp.net,dataset,C#,Asp.net,Dataset,我相信我的datatable需要在最后一条语句中循环,以提取两个datatable并将它们组合起来 我的问题是,我对所有这些都是新手,我对数据集有一些简单的了解,但我还没有一点线索将它们连接起来 它也要求我在编辑中写更多的细节,所以我不知道我还能在这里写些什么:)对不起,表格出现了错误。。。所以标题是正确的,但是hr1-hr2等在左边,目标在相应的列标题下面,所以你有两个数据集,每个表有5列?第一列是键?有点不清楚是什么阻止你加入他们。您是否尝试过选择或查找?您好,我被告知要将两个表绑定在一起并
它也要求我在编辑中写更多的细节,所以我不知道我还能在这里写些什么:)对不起,表格出现了错误。。。所以标题是正确的,但是hr1-hr2等在左边,目标在相应的列标题下面,所以你有两个数据集,每个表有5列?第一列是键?有点不清楚是什么阻止你加入他们。您是否尝试过选择或查找?您好,我被告知要将两个表绑定在一起并创建一个新的数据表。。并将数据集作为参数传递。。。我对这一切都是陌生的,而且还在挣扎。。。我想我需要一个foreach循环来连接这两个集合,但还没有得到一个线索:(所以我只需要从第二个表中获取实际值,显然不需要它的标题..像这样的东西可能会起作用,或者这样:
Ok so I have a stored proc that returns two table dataset [0] + dataset [1]
Can anybody help in figuring how I can loop through the second set of results and join certain columns to the first table?
Basically what I have is targets and actuals e.g.
A B C D
hr1 10 22 23 23
hr2 20 233 222 232
hr3 22 2334 333 3344
And the table [1] is exactly the same but with the actual targets...
What I am trying to do it add the actuals next to the targets
So for instance A B C D will have the actuals next to the targets...
Hope this is clear... I have also been told to create indexs...
Code so far -- Default aspx - main entry for the web page
public void Refreshdata(int selectedProduct)
{
BizManager biz = new BizManager();
GridView1.DataSource = biz.GetPacktstatisticsForShift( new
DateTime(2016, 4, 1, 6, 0, 0)
, new DateTime(2016, 4, 16, 13, 59, 59)
, selectedProduct).Tables[0].DefaultView;
GridView1.DataBind();
}
Datamanager class - datamanger class code
public DataSet TargetQuantites(int itemSeriesMasterId, DateTime
shiftstart, DateTime shiftend)
{
object[] args = new object[3] { itemSeriesMasterId, shiftstart,
shiftend};
return CallSp(MethodBase.GetCurrentMethod(), args) as DataSet;
}
}
bizmanager class - code class
public DataSet GetPacktstatisticsForShift(DateTime shiftStart, DateTime shiftEnd, int seriesMasterId)
{
using (DataManager dmgr = new DataManager())
{
dmgr.Connect(ConfigurationManager.AppSettings["ProductionKey"]);
DataSet dset = dmgr.TargetQuantites(seriesMasterId, shiftStart, shiftEnd);
dmgr.Disconnect();
return CreatePackingStats(dset);
}
}
private DataSet CreatePackingStats(DataSet dset)
{
using (DataManager dmgr = new DataManager())
{
foreach (DataTable table in dset.Tables)
{
foreach (var VARIABLE in table)
{
}