title: Check for existence of ID before deleting the record in C# and MS Access
body: <p>I am a new C# and MS Access user, I am making a car insurance program. When trying to delete users, the ID is inserted and the delete process is carried out normally. However, if an ID which does not exist is entered, the program still says "record deleted". This is my code:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          try
          {
              if (MessageBox.Show("Are you sure you want to delete?", "WARNING!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
              {
                  con.Open();
                  cmd.Connection = con;
  
  
                  string q = "delete from Users where ID=" + numericUpDown1.Value.ToString();
                  deletedata(q);
                  cmd.ExecuteNonQuery();
                  MessageBox.Show("Record Deleted");
                  numericUpDown1.Value = 0;
                  con.Close();
              }
              else
                  Close();
          }
          catch (Exception ex)
          {
              con.Close();
              MessageBox.Show(ex.Message);
  
          }
  
  
      }
  
  
      private void deletedata(String q)
      {
          try
          {
              cmd.CommandText = q;
          }
          catch (Exception ex)
          {
              con.Close();
              MessageBox.Show(ex.Message.ToString());
  
          }
  
      }
  </code></pre>