DataSet从两个不同的表连接列并使用索引

时间:2018-05-08 08:56:06

标签: c# asp.net dataset

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)
            {

            }

我相信我的数据表需要在最后一个语句中循环以拉出两个数据表并将它们组合起来吗?

我的麻烦是我对这一切都是新手,我简单地了解了数据集,但我还没有得到加入它们的线索......

它要求我在我的编辑中写下更多细节,所以我不知道我还能在这里写些什么:)

0 个答案:

没有答案