title: Delete a row from a MySQL database only if certain conditions are met
body: <p>I'm currently working on a simple windows form bug reporter for university and am having trouble. I'm trying to create a query where the user can only delete the bug if:</p>
  
  <ul>
  <li>The bug name exists</li>
  <li>The user logged in matches the user that reported the bug.</li>
  </ul>
  
  <p>Currently no matter which use is logged in, the query always returns 'Incorrect User Logged In!' and doesn't delete the bug.</p>
  
  <p>I am a novice at both C# and MySQL, so I'm sure my code isn't the best way of writing it. I apologize if it is hard to read.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is my current code based on the below answer which still doesnt work. I currently get could not find specified colum in results: bug_submitted_by</p>
  
  <pre><code> connection = new MySqlConnection(connectionString);
                  string check = "SELECT COUNT(*) FROM bugs WHERE bug_name ='" + this.txt_bug_name.Text + "'AND bug_submitted_by='" + this.lbl_user.Text + "';";
                  MySqlCommand cmd = new MySqlCommand(check, connection);
                  MySqlDataReader reader;
                  connection.Open();
                  reader = cmd.ExecuteReader();
                  if (reader.Read())
                  {
  
                      if (reader.GetString("bug_submitted_by").Equals(this.lbl_user.Text))
                      {
                          reader.Close();
                          cmd.Dispose();
                          string query = "DELETE from bugs WHERE bug_name='" + this.txt_bug_name.Text + "';";
                          MySqlCommand cmd2 = new MySqlCommand(query, connection);
                          MySqlDataReader reader2;
                          reader2 = cmd2.ExecuteReader();
                          lbl_message.Text = "Bug Deleted!";
                          reader2.Close();
                          cmd2.Dispose();
                          connection.Close();
                          load_table();
                          Combo_selection();
                          reset(this);
  
                      }
                      else
                      {
                          lbl_message.Text = "Incorrect user!";
                          reader.Close();
                          cmd.Dispose();
                          connection.Close();
                          cb_names.SelectedIndex = -1;
                      }
                  }
                  else
                  {
                      lbl_message.Text = "Bug Doesn't Exist!";
                  }
  </code></pre>