title: How to Store list of data from Database to ArrayList or List in C#
body: <p>Table: employee</p>
  
  <pre><code>code|Name|Left
  ----+----+----
  1   | A  | Y
  2   | B  | N
  3   | C  | N
  4   | D  | Y
  5   | E  | N
  6   | F  | Y
  </code></pre>
  
  <p>now i am doing ,</p>
  
  <pre><code>        SqlConnection cn=new SqlConnection();
          SqlCommand cmd = new SqlCommand();
          cn.ConnectionString="&lt;CONNECTION STRING&gt;"
          List&lt;string&gt; str = new List&lt;string&gt;();
          cmd.Connection=cn;
          cmd.Connection.Open();
          cmd.CommandText="Select code from employee where Left='Y'";
          SqlDataReader dr=cmd.executeReader();
          while(dr.Read())
          {
                         str.Add(dr1.GetValue(0).ToString());
  
          }
  
          foreach (string p in str)
          {
                   Response.Write(p);
          }
  </code></pre>
  
  <p>This code fetch only 1 data, how may i get all data whose Left='Y'</p>