title: retrieving data from sql database using C# with stored procedure
body: <p>Whenever I try to retrieve data from my database i keep getting null. The code i'm using is below: </p>
  
  <pre><code>protected void Button2_Click(object sender, EventArgs e)
   {
      SqlConnection myConnection = new SqlConnection(GetConnectionString());
      SqlCommand cmd = new SqlCommand("spSelectCustomer", myConnection);
      cmd.CommandType = CommandType.StoredProcedure;
      myConnection.Open();
  
      SqlParameter custId = cmd.Parameters.Add("@CustomerId", SqlDbType.Int);
      custId.Direction = ParameterDirection.Input;
      custId.Value = 10;
  
      SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
  
      Label1.Text = dr["FirstName"].ToString();
      Label2.Text = dr["LastName"].ToString();
      Label3.Text = dr[3].ToString();
      Label4.Text = dr["Email"].ToString();
  }
  private static string GetConnectionString()
  {
      return ConfigurationManager.ConnectionStrings["Lab3ConnectionString"].ConnectionString;
  }
  </code></pre>