title: How can I retrieve data from mysql database
body: <p>This code is from our user login profile for our SAD project. The account I register for user log in is working since it saved in the database but I can't log in because it says invalid.</p>
  
  <pre><code>private void btn_login_Click(object sender, EventArgs e)
          {
              conn = new MySqlConnection(myconn);
              string query = "select * from southpoint_school.user where userUsername='" + textBox1.Text + "' and userPassword='" + textBox2.Text + "'";
              conn.Open();
             cmd = new MySqlCommand(query, conn);
  
         MySqlDataReader reader = cmd.ExecuteReader();
          int count = 0;
  
          while (reader.Read())
          {
              count++;
          }
  
          if (count == 1)
          {
              conn = new  MySqlConnection(myconn);
  
              string problem = "SELECT userAccountType from southpoint_school.user WHERE userUsername ='" + textBox1.Text + "'";
              conn.Open();
              cmd = new MySqlCommand(problem, conn);
              string answer = cmd.ExecuteScalar().ToString();
              conn.Close();
  
              MessageBox.Show("Login successful!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  
              if (answer == "Administrator")
              {
                  memorable = "Administrator";
  
                  frm_main main = new frm_main();
                  main.Show();
                  this.Hide();
              }
              else
              {
                  memorable = "Limited";
  
                  frm_main main = new frm_main();
                  main.Show();
                  this.Hide();
              }
          }
          else if (textBox1.Text == "" &amp;&amp; textBox2.Text == "")
          {
              MessageBox.Show("No Username and/or Password Found!");
          }
          else
          {
              MessageBox.Show("Invalid Username And/Or Password!");
          }
          conn.Close();
      }
  </code></pre>