I am currently writing my first .Net & C# application with Visual Studio, and have a need to write generated values to MySQL from the application. 
At present, I can write values fine - but I need to be able to check to see if a value exists and display that line if it does exist, otherwise insert new line to table. My connection string is defined at the top of the form.

I have the following defined already, and it writes to the database successfully if no duplicate values exist in the LicenseKey column. If a duplicate exists, it throws an unhandled exception.

```cs
private void SaveDetails()
{
    // MySQL 'insert' command
    string InsertNewLicense = "insert into BCOM.LicenseDetails(LicenseeName,ComputerName,ContactName,ContactEmail,LicenseKey,CreationDate) values('" +this.textBoxLicenseeName.Text+ "','" +this.textBoxComputerName.Text+ "','" +this.textBoxContactName.Text+ "','" +this.textBoxContactEmail.Text+ "','" +this.textBoxLicenseKey.Text+ "','" +this.textBoxCreationDate.Text+ "');";
    //MySQL instance details
    MySqlConnection InsertLicenseDetails = new MySqlConnection(LicenseDatabaseConnection);
    //MySQL command execution
    MySqlCommand InsertCommand = new MySqlCommand(InsertNewLicense, InsertLicenseDetails);
    // Handles command outputs.
    MySqlDataReader InsertReader;
    //Opens connection to run query on database
    InsertLicenseDetails.Open();
    // Here our query will be executed and data saved into the database.
    MessageBox.Show("License Details Saved. Please ensure you have emailed the license to the customer.");
    while (InsertReader.Read())
    {

    }
    InsertLicenseDetails.Close();
}

```

What I want to happen is for a check to be run on the LicenseKey column to see if the value exists, before different actions are taken.
If the value does not exist, I would like to insert the new line to the table (like my existing command does). 

If, however, the value *does* exist, I would like to pop up a form showing the values from the line that the duplicate appears in as a form.

Where would I put in an event handler to read MySQLException values? What exception would I have to respond to for a duplicate value or no database response?