Results 1 to 2 of 2

Thread: [RESOLVED] Query not execute when I trap Button click

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Resolved [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.
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    Re: Query not execute when I trap Button click

    Sorry....
    I found my fault

    I'd use YesNo in case. but my buttons are OkCancel

    Resolved...
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width