[RESOLVED] Query not execute when I trap Button click
QUery not executed when I use a Button Click on my MessageBox.
Here is my code
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;
}
Also I need to trap if string delID holds a value.
Re: Query not execute when I trap Button click
Sorry....
I found my fault :D
I'd use YesNo in case. but my buttons are OkCancel
Resolved...