QUery not executed when I use a Button Click on my MessageBox.
Here is my code
Also I need to trap if string delID holds a value.Code:con = new SqlConnection(); con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\MyRecords\\pData.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlCommand nonqueryCommand = con.CreateCommand(); string delID = label8.Text; switch (MessageBox.Show("Delete Client: " + delID + " " + label9.Text + ", " + label10.Text + " ", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { case DialogResult.Yes: con.Open(); nonqueryCommand.CommandText = "DELETE FROM tblClients WHERE p_ID='" + delID + "'"; nonqueryCommand.ExecuteNonQuery(); con.Close(); break; case DialogResult.No: // "No" processing break; }




Reply With Quote