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

            }

i believe my datatable needs to loop in this last statement to pull the two datatables and combine them??

My trouble is i am new to all this and i understand briefly about datasets but i havent got a clue to join them up...

Its asking me too write more details in my edit, so i dont know what else i can write here :)

  • sorry the table came out wrong... so the heading are correct but hr1 - hr2 etc is on the left side with the targets underneath the corresponding column headings –  May 08 '18 at 08:57
  • so you have two datasets where each table has 5 columns? The first column is the key? It is a bit unclear what is keeping you from joining them. Did you try with Select or Find? – rene May 08 '18 at 09:07
  • Hi, i was told to bind the two tables together and create a new data table.. and pass the dataset as an argument... I am new to all of this and struggling... i think i will need a foreach loop to join the two sets, but havent got a clue :( –  May 08 '18 at 09:25
  • so i only need to grab the actuals from the second table, and obviously not the heading with it.. –  May 08 '18 at 09:26
  • something like this might work https://stackoverflow.com/questions/19517207/datatables-dynamic-join or this: https://stackoverflow.com/questions/27913802/how-to-join-datatable – rene May 08 '18 at 09:33

0 Answers0