Hello Experts,
With the following code . I want to catch the mysql primery key error and want to throw the message to the user that is record is already present you cant add this .
void SaveQuery()
{
MySqlCommand com = new MySqlCommand();
com.CommandText = "Insert Into feest (fyear,strcode,stclass,tfees,sfees,mfees,trfees,oth1,oth2,oth3,oth4,oth5,oth6) Values ('" +comboBox1.Text+ "','" + comboBox2.Text + "','"
+ comboBox3.Text + "','" + maskedTextBox1.Text + "','" + maskedTextBox2.Text + "','" + maskedTextBox3.Text + "','" + maskedTextBox4.Text + "','" + maskedTextBox5.Text + "','"
+ maskedTextBox6.Text + "','" + maskedTextBox7.Text + "','" + maskedTextBox8.Text + "','" + maskedTextBox9.Text + "','" + maskedTextBox10.Text + "')";
com.Connection = con_db.con;
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
MessageBox.Show(" Record successfully saved", " Fees Structure Setup Module ", MessageBoxButtons.OK, MessageBoxIcon.Information);
This code works fine . But when user enters duplicate record it goes to debug windows. Instad of that I want to show the Duplicate record error. to user . Thanks in advance
Regards
Anand