title: Trouble with else not executing
body: <p>I'm having trouble with my if statement not working 100%.</p>
  
  <p>When the criteria for the if statement = true then everything works out fine,
  but when the criteria doesn't = true the else part does not execute.</p>
  
  <p>This is my 3rd day in trying to  develop in C#, so I don't know if I'm just doing it all wrong... and if I'm busy being a noob, suggestions on improving this code would be highly appreciated.</p>
  
  <p>So please help with the if statement and improving the code ?</p>
  
  <pre><code>        using (SqlConnection sqlConnection2 = new SqlConnection("Data Source=SCIENTIFICFS;Initial Catalog=TL_ScientificInstruments;Persist Security Info=True;User ID=Reports;Password=Reports"))
          {
              sqlConnection2.Open();
              using (SqlCommand cmd = new SqlCommand("Select * From tbl_ScientificEng_Product_Info Where Syspro_StockCode = '" + product.Trim() + "'", sqlConnection2))
              {
                  SqlDataReader reader2;
                  reader2 = cmd.ExecuteReader();
                  while (reader2.Read()) {
                      if (reader2.HasRows)
                      {
                          textBox4.Text = reader2.GetString(0);
                          textBox5.Text = reader2.GetString(1);
                          textBox6.Text = reader2.GetString(2);
                          textBox7.Text = reader2.GetString(3);
                          textBox8.Text = reader2.GetString(4);
                          textBox9.Text = reader2.GetString(5);
                          textBox10.Text = reader2.GetString(6);
  
                          label19.Visible = true;
                          label10.Visible = false;
  
                          textBox11.Enabled = false;
                          textBox12.Enabled = false;
                          textBox13.Enabled = false;
                          textBox14.Enabled = false;
                          textBox15.Enabled = false;
                          textBox16.Enabled = false;
                          textBox17.Enabled = false;
  
                          button2.Enabled = false;
                      }
                      else {
                          MessageBox.Show("In Else Statement");
                          using (SqlCommand cmd2 = new SqlCommand("Select top 1 * from tbl_ScientificEng_Product_Info Where Syspro_StockCode like Left('" + product.Trim() + "%',7)", sqlConnection2)) {
                              SqlDataReader reader3;
                              reader3 = cmd2.ExecuteReader();
                              while (reader3.Read()) {
                                  textBox4.Text = reader3.GetString(0);
                                  textBox5.Text = reader3.GetString(1);
                                  textBox6.Text = reader3.GetString(2);
                                  textBox7.Text = reader3.GetString(3);
                                  textBox8.Text = reader3.GetString(4);
                                  textBox9.Text = reader3.GetString(5);
                                  textBox10.Text = reader3.GetString(6);
  
                                  label19.Visible = false;
                                  label10.Visible = true;
                              }
                              //reader3.Close();
                          }
                          //reader2.Close();
                      }
                  }
              }
          }  
  </code></pre>
  
  <p>Thanks in advance.</p>