private void button2_Click(object sender, EventArgs e) { try { if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text== ""|| textBox3.Text == "") { MessageBox.Show("Missing information"); } else { Con.Open(); if (int.TryParse(textBoxCId.Text, out int CId)) { SqlCommand cmd = new SqlCommand("UPDATE EventTbl SET CName=@CN,CPhone=@CP,Events=@E,Date=@D WHERE CId=@key", Con); cmd.Parameters.AddWithValue("@CN", textBox1.Text); cmd.Parameters.AddWithValue("@CP", textBox2.Text); cmd.Parameters.AddWithValue("@E", comboBox1.Text); cmd.Parameters.AddWithValue("@D", textBox3.Text); cmd.Parameters.AddWithValue("@key", CId); cmd.ExecuteNonQuery(); Con.Close(); MessageBox.Show("Record Update Sucessfully"); DisplayEvent(); } else { MessageBox.Show("Invalid CId. Please enter a valid integer value."); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Con.Close(); } }
ExecuteNonQuery
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)