title: get all row and column data using SELECT - C#
body: <p>I'm trying to get all data from an SQL table and store it in a List using the C# programming language.</p>
  
  <p>the SQL statement I'm using is:</p>
  
  <pre><code>private string cmdShowEmployees = "SELECT * FROM Employees;";
  </code></pre>
  
  <p>This is being used in the same class as a function</p>
  
  <pre><code>public List&lt;string&gt; showAllIdData()
  {
    List&lt;string&gt; id = new List&lt;string&gt;();
    using (sqlConnection = getSqlConnection())
    {
      sqlCommand.Connection = sqlConnection;
      sqlCommand.CommandText = cmdShowEmployees;
      SqlDataReader reader = sqlCommand.ExecuteReader();
      while (reader.Read()) {
        id.Add(reader[0].ToString());
      }
      return id;
    }
  }
  </code></pre>
  
  <p>and here</p>
  
  <pre><code>public List&lt;string&gt; showAllActiveData()
  {
    List&lt;string&gt; active = new List&lt;string&gt;();
    using (sqlConnection = getSqlConnection())
    {
      sqlCommand.Connection = sqlConnection;
      sqlCommand.CommandText = cmdShowEmployees;
      SqlDataReader reader = sqlCommand.ExecuteReader();
      while (reader.Read()) {
        active.Add(reader[1].ToString());
      }
      return active;
    }
  </code></pre>
  
  <p>I would have to create 9 more functions this way in order to get all the data out of the Employees table.  This seems very inefficient and I was wondering if there was a more elegant way to do this.  </p>
  
  <p>I know using an adapter is one way to do it but I don't think it is possible to convert a filled adapter to a list, list list etc.</p>
  
  <pre><code>SqlDataAdapter adapter = sqlDataCollection.getAdapter();
  DataSet dataset = new DataSet();
  adapter.Fill(dataset, "idEmployees");
  dataGridView1.DataSource = dataset;
  dataGridView1.DataMember = "idEmployees";
  </code></pre>
  
  <p>Any ideas?</p>