title: Save all records from one table column in an array
body: <p>I want to store all records from a MySQL table column in an array (C#).</p>
  <p>E.g. if there is the column &quot;name&quot; in a table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>name</th>
  <th>other column</th>
  <th>...</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Peter</td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Marc</td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Henry</td>
  <td></td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>... I want to store these names as elements in an array/list programmatically. The goal is to be able to access each element (in this case name) itself and going on with that.</p>
  <p>Using a MySqlDataReader didn't work out that good, because it only returned me the last record in the column:</p>
  <pre><code>conn.Open();
  string getNameQuery = &quot;SELECT * FROM myTable&quot;;
  MySqlCommand getName = new MySqlCommand(getNameQuery, conn);
  dataReader = getName.ExecuteReader();
  while(dataReader.Read())
  {
      dataReader.getString(&quot;name&quot;);
  }
  conn.Close();
  </code></pre>