title: C# Error: Index was outside the bounds of the array
body: <p>i am getting an "Index was outside the bounds of the array." at dr1[1].ToString().</p>
  
  <p>I have table contribution_master with 3 columns: type_id (int), name (varchar(20), amount (float).
  I want to extract all the amount rows.</p>
  
  <pre><code>SqlConnection SQLCon1 = new SqlConnection(ConfigurationManager.ConnectionStrings["PayrollConnStr"].ConnectionString.ToString());
  
      SqlCommand SQLCmd1 = new SqlCommand("SELECT amount FROM contribution_master", SQLCon1);
  
      try
      {
          SQLCon1.Open();
          SqlDataReader dr1 = SQLCmd1.ExecuteReader();
          while (dr1.Read())
          {
              employer_epf = Convert.ToDouble(dr1[0].ToString());
              employer_admin = Convert.ToDouble(dr1[1].ToString());
              employer_edli = Convert.ToDouble(dr1[2].ToString());
              employer_admin_edli = Convert.ToDouble(dr1[3].ToString());
              employer_esi = Convert.ToDouble(dr1[4].ToString());
          }
      }
      catch (SqlException ex)
      {
          string errorMessage = "Error ";
          errorMessage += ex.Message;
          lblWarn.Text = errorMessage;
          lblWarn.Visible = true;
      }
      finally
      {
          SQLCon1.Close();
      }
  </code></pre>