title: Update SQL query, unsure why it isn't working as no errors are appearing
body: <p>I have been staring at this UPDATE statement for a long while and are unsure why my table isn't changing. When I press the button no error appears but my table doesn't not get updated either, I have checked that all of my variables have values on debug and they do.</p>
  
  <p>I'd appreciate any help anyone can give me!</p>
  
  <p>This is the code that contains the statement I need help with: </p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
  
          string studentanswertext = textBox1.Text;
          string connectionString = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
          string y = GlobalVariableClass.Signedinteacher;
          Convert.ToInt32(y);
          MessageBox.Show(y);
  
          MessageBox.Show(Convert.ToString(CurrentQuestionID));
          MessageBox.Show(studentanswertext);
          SqlConnection connect = new SqlConnection(connectionString);
          connect.Open();
  
          SqlCommand command20 = new SqlCommand(@"UPDATE QuestionStudentAssociation SET ([StudentAnswer]=@StudentAnswertext) WHERE ([QuestionID]=@CurrentQID AND [StudentID]=@SignedinStudent )", connect);
          command20.Parameters.AddWithValue("@StudentAnswertext", studentanswertext);
          command20.Parameters.AddWithValue("@CurrentQID", CurrentQuestionID);
          command20.Parameters.AddWithValue("@SignedinStudent", y);
          command20.BeginExecuteNonQuery();
  
  
          connect.Close();
      }
  </code></pre>
  
  <p>This is the whole code for my form if anyone wanted to look at it just in case that is affecting the button even handler:</p>
  
  <pre><code> namespace ComputingA2_Official_Project
  {
  public partial class CurrentlySetTestForm : Form
  
  {
      Timer loopTimer = new Timer();
      private int CurrentQuestionID { get; set; }
      private string QuestionSpace { get; set; }
      public CurrentlySetTestForm()
      {
          InitializeComponent();
      }
  
      private void CurrentlySetTestForm_Load(object sender, EventArgs e)
      {
  
          string y = GlobalVariableClass.Signedinteacher;
  
          Convert.ToInt32(y);
  
          string connectionString = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
          SqlConnection connect = new SqlConnection(connectionString);
  
          connect.Open();
  
          SqlCommand command18 = new SqlCommand("SELECT MIN([QuestionID]) AS QuestionID FROM QuestionStudentAssociation WHERE ( [StudentID]=@Signedinstudent AND [StudentAnswer] IS NULL )", connect);
          command18.Parameters.AddWithValue("@Signedinstudent", y);
  
          var reader = command18.ExecuteReader();
          while (reader.Read())
          {
              CurrentQuestionID = Convert.ToInt32(reader[0]);
  
              SqlCommand command19 = new SqlCommand("SELECT ([Question Space]) FROM Questions WHERE ([QuestionID]=@CurrentQID)", connect);
              command19.Parameters.AddWithValue("@CurrentQID", CurrentQuestionID);
  
  
              using (SqlDataReader reader2 = command19.ExecuteReader())
              {
                  while (reader2.Read())
                  {
                      QuestionSpace = Convert.ToString(reader2[0]);
                      label1.Text = QuestionSpace;
                  }
              }
           }
  
          connect.Close();
  
      }
  
      private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
  
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
  
          string studentanswertext = textBox1.Text;
          string connectionString = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
          string y = GlobalVariableClass.Signedinteacher;
          Convert.ToInt32(y);
          MessageBox.Show(y);
  
          MessageBox.Show(Convert.ToString(CurrentQuestionID));
          MessageBox.Show(studentanswertext);
          SqlConnection connect = new SqlConnection(connectionString);
          connect.Open();
  
          SqlCommand command20 = new SqlCommand(@"UPDATE QuestionStudentAssociation SET ([StudentAnswer]=@StudentAnswertext) WHERE ([QuestionID]=@CurrentQID AND [StudentID]=@SignedinStudent )", connect);
          command20.Parameters.AddWithValue("@StudentAnswertext", studentanswertext);
          command20.Parameters.AddWithValue("@CurrentQID", CurrentQuestionID);
          command20.Parameters.AddWithValue("@SignedinStudent", y);
          command20.BeginExecuteNonQuery();
  
  
          connect.Close();
      }
  
      private void timer1_Tick(object sender, EventArgs e)
      {
  
  
  
      }
  }
  
  }
  </code></pre>