title: C# Read multiple rows from different columns sharing same Foreign key SQL
body: <p>I want an efficient way to retrieve all info that shares the same Foreign key in a table, and store the data in list/array.</p>
  
  <p>I can read several rows from one column:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
  
  int idForeignKey = inputIdFkey //Implemented on the WebPage for testing purposes
  
  List&lt;string&gt; result = new List&lt;string&gt;();
  string oString = "Select Column from Table where foreignKey = @fKey";
  
  conn.Open();
  SqlCommand oCmd = new SqlCommand(oString, conn);
  oCmd.Parameters.AddWithValue("@fKey", idForeignKey);
  using (SqlDataReader oReader = oCmd.ExecuteReader())
  {
      while (oReader.Read())
      {
          result.Add(oReader.GetString(0));
      }
  }
  conn.Close();
  </code></pre>
  
  <p>And I can read several columns if I am targeting one specific row:</p>
  
  <pre><code>int sqlData1;
  int sqlData2;
  int sqlData3;
  
  string oString = "Select * from Table where TableID = @tId";
  SqlCommand oCmd = new SqlCommand(oString, conn);
  oCmd.Parameters.AddWithValue("@tId", 1001);
  conn.Open();
  using (SqlDataReader oReader = oCmd.ExecuteReader())
  {
      while (oReader.Read())
      {
          sqlData1 = oReader["Row1"].ToString();
          sqlData2 = oReader["Row2"].ToString();
          sqlData3 = oReader["Row3"].ToString();
      }
  }
  conn.Close();
  </code></pre>
  
  <p>But I would love to be able to read all/specific data that has the same foreign key. So I want to be able to retrieve several rows, save them to a list, and retrieve several other row data from a different column that shares the same foreign key. </p>
  
  <p>I imagine it to be something like this:</p>
  
  <pre><code>int idForeignKey = inputIdFkey //Implemented on the WebPage for testing purposes
  
  List&lt;int&gt; intList = new List&lt;int&gt;();
  List&lt;string&gt; stringList = new List&lt;string&gt;();
  List&lt;DateTime&gt; dateList = new List&lt;DateTime&gt;();
  
  string oString = "Select * from Table where ForeignKey = @fKey";
  
  conn.Open();
  SqlCommand oCmdSleep = new SqlCommand(oString, conn);
  oCmdSleep.Parameters.AddWithValue("@fKey", idForeignKey);
  using (SqlDataReader oReader = oCmdSleep.ExecuteReader())
  {
      while (oReader.Read())
      {
          intList.Add(oReader["Column1"].GetDateTime(0));
          dstringList.Add(oReader["Column3"].GetDateTime(0));
          dateList.Add(oReader["Column4"].GetDateTime(0));
      }
  }
  conn.Close();
  </code></pre>
  
  <p>But this does not working... Please advice me</p>