c# - Update SQL query, unsure why it isn't working as no errors are appearing -


i have been staring @ update statement long while , unsure why table isn't changing. when press button no error appears table doesn't not updated either, have checked of variables have values on debug , do.

i'd appreciate can give me!

this code contains statement need with:

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) ([questionid]=@currentqid , [studentid]=@signedinstudent )", connect);         command20.parameters.addwithvalue("@studentanswertext", studentanswertext);         command20.parameters.addwithvalue("@currentqid", currentquestionid);         command20.parameters.addwithvalue("@signedinstudent", y);         command20.beginexecutenonquery();           connect.close();     } 

this whole code form if wanted @ in case affecting button handler:

 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]) questionid questionstudentassociation ( [studentid]=@signedinstudent , [studentanswer] 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]) questions ([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) ([questionid]=@currentqid , [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)     {        } }  } 

i believe issue executing command asynchronously (beginexecutenonquery), never calling endexecutenonquery commit it. suspect call synchronously this:

command20.executenonquery();