private void Add_Click(object sender, EventArgs e) { string errorMsg; if (!ValidFirstName(FirstName.Text, out errorMsg)) { // Cancel the event and select the text to be corrected by the user. // Set the ErrorProvider error with the text to display. Alert.Show(errorMsg); } if (!ValidLastName(LastName.Text, out errorMsg)) { // Cancel the event and select the text to be corrected by the user. // Set the ErrorProvider error with the text to display. Alert.Show(errorMsg); } else if (!ValidEmailAddress(Email.Text, out errorMsg)) { // Set the ErrorProvider error with the text to display. Alert.Show(errorMsg); } else { if (mysqlConn.connOpen() == true) { var Name = LastName.Text + " " + FirstName.Text; mysqlConn.insertCustomer(Name, FirstName.Text, LastName.Text, TelNum.Text, address.Text, city.Text, Email.Text, country.Text); dataGridView1.DataSource = mysqlConn.qry("SELECT * FROM `tblCustomer`").Tables[0]; Name = ""; } } }