title: how to put validation for certain empty textbox
body: <p>How can i put validation for txtPName and txtAddress if they are empty i cannot proceed to submit and a messagebox will pop up. </p>
  
  <pre><code>private void btnSubmit_Click(object sender, EventArgs e)
      {
  
          string insertQuery = "INSERT INTO patientdb.addpatient(PatientName,MobileNumber,Occupation,Gender,Address,Age,PhoneNumber,MedicalHistory,ChiefComplaint) VALUES ('" + txtPName.Text + "','" + txtMNum.Text + "','" + txtOccup.Text + "','" + comboBox1.Text + "','" + txtAddress.Text + "','" + txtAge.Text + "','" + txtPNum.Text + "','" + rtbMHistory.Text + "','" + rtbCC.Text + "')";
          con.Open();
          MySqlCommand command = new MySqlCommand(insertQuery, con);
  
          try
          {
              if (command.ExecuteNonQuery() == 1)
              {
                  MessageBox.Show("Data Inserted");
                  txtPName.Text = "";
                  txtMNum.Text = "";
                  txtPNum.Text = "";
                  txtAddress.Text = "";
                  txtAge.Text = "";
                  txtOccup.Text = "";
                  rtbMHistory.Text = "";
                  rtbCC.Text = "";
                  comboBox1.Text = " ";
              }
              else
              {
                  MessageBox.Show("Data Not Inserted");
              }
          }
  </code></pre>