private void btnDelete_Click(object sender, EventArgs e) { if (!FormValidate()) { DialogResult result; result = MessageBox.Show("Are you sure want to Delete the record?", "Conformation", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { string conString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString; OleDbConnection con = new OleDbConnection(conString); string strDelete = "delete from GenericNames where id=@id"; OleDbCommand cmd = new OleDbCommand(strDelete, con); cmd.Parameters.AddWithValue("@id", txtID.Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Records Successfully Deleted", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information); LoggingHelper.LogEntry("Generic Names", "Delete", txtGenericName.Text, int.Parse(txtID.Text.Trim())); FormRefresh(); } } }