title: How to fill DataTable from multiple tables?
body: <p>I have written a stored procedure which gives me result from 3 tables separately. Please have a look on the screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/LKrCW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LKrCW.png" alt="enter image description here"></a></p>
  
  <p><code>DataTable dataTable = ds.Tables[0];</code> gives me top result from screenshot, <code>DataTable dataTable = ds.Tables[1];</code> gives me middle one from screenshot and <code>ds.Tables[2];</code> gives me last one.</p>
  
  <p>Now, I want to get all the table information. Please have a look on my code. I am not getting the result.</p>
  
  <blockquote>
    <p>System.ArgumentException: 'Column 'race_header' does not belong to
    table Table2.'</p>
  </blockquote>
  
  <p>Please provide the solutions for this.</p>
  
  <pre><code>public List&lt;ClsStakesRaces&gt; RaceNameDetails(int? Id)
          {
              List&lt;ClsStakesRaces&gt; clsStakes = new List&lt;ClsStakesRaces&gt;();
  
              SqlParameter[] prms = new SqlParameter[1];
              string sSQL;
              sSQL = "exec StakesRacesGetRaceDetails @Id";
              prms[0] = new SqlParameter("@Id", SqlDbType.Int);
              prms[0].Value = Id;
              ds = clsUtilities.CreateCommandwithParams(sSQL, prms);
              DataTable dataTable = new DataTable();
              dataTable = ds.Tables[0];
              dataTable= ds.Tables[1];
              dataTable = ds.Tables[2];
              foreach (DataRow dr in dataTable.Rows)
              {
                  clsStakes.Add(
                      new ClsStakesRaces
                      {
                          RaceName = Convert.ToString(dr["race_header"]),
  
                          HorseId = Convert.ToInt32(dr["HorseID"]),
                          Horse = Convert.ToString(dr["Horse"]),
                          Details = Convert.ToString(dr["Details"]),
                          Breeding = Convert.ToString(dr["Breeding"]),
                          Earning = Convert.ToDecimal(dr["Earning"]),
  
                          PreviousWinner = Convert.ToString(dr["PreviousWinners"])
                      });
              }
              return clsStakes;
          }
  </code></pre>