title: How to use UPDATE in ado net
body: <p>I need to perform an update in a table(Homework). But it is not just replacing an old value with a new one; to the already existing value in the column i have to add(SUM) the new value(the column is of type int).
  This is what i did so far but i am stuck:</p>
  
  <pre><code>protected void subscribeButton_Click(object sender, EventArgs e)
      {
          string txtStudent = (selectedStudentLabel.Text.Split(' '))[0];
          int studentIndex = 0;
          studentIndex = Convert.ToInt32(txtStudent.Trim());        
  
          SqlConnection conn = new SqlConnection("Server=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Trusted_Connection=True;User Instance=yes");
          conn.Open();
          string sql2 = "UPDATE student SET moneyspent = " + ?????? + " WHERE id=" + studentIndex + ";";
          SqlCommand myCommand2 = new SqlCommand(sql2, conn);
  
          try
          {
              conn.Open();
              myCommand2.ExecuteNonQuery();
          }
          catch (Exception ex)
          {
              Console.WriteLine("Error: " + ex);
          }
          finally
          {
              conn.Close();
          }
      }
  </code></pre>
  
  <p>What should i add intead of <strong>???</strong> to achieve my goal?</p>
  
  <p>Is it possible to do it this way? I want to avoid using to many queries.</p>