private void button2_Click(object sender, EventArgs e) { if (textBox2.Text == textBox3.Text) { int password = 0; try { password = Convert.ToInt32(textBox2.Text); } catch { MessageBox.Show("password should contain only number"); } if (password.ToString().Length >= 4) { con.Open(); SqlCommand cmd1 = con.CreateCommand(); cmd1.CommandType = CommandType.Text; cmd1.CommandText = "update customer set password='******' where cust_id='" + cust_id + "'"; cmd1.ExecuteNonQuery(); MessageBox.Show("Password changed please logout"); con.Close(); this.Close(); login l = new login(); l.ShowDialog(); } else { MessageBox.Show("password should be more than 3 number"); textBox2.Clear(); textBox3.Clear(); } } else { MessageBox.Show("password not matched"); textBox2.Clear(); textBox3.Clear(); } }