title: Updating row in database using vb.net
body: <p>I am trying to update and save a row of a database table. I have used a version of this code to just populate a  GridView and it works, so I am assuming it has something to do with my SQL statment; I do not get an error, the table just does not update. On the page load event I have the textboxes being populated by the information of the row, and I have a global variable, named 'temp', that will save the title of the row so I can use it in the button's click event. The error I am getting states that I have not given a value for one of my required parameters. My Locals tab on the debugger shows that every variable has a value, though the one I try to update is not the new data but still the old data.
  I have looked at several examples and I cannot find the problem though. Thank you for any assistance.</p>
  
  <pre><code>Protected Sub btnSave_Click(sender As Object, e As EventArgs)
  
      Dim strTitle As String = txtTitle.Text
      Dim strConsole As String = txtConsole.Text
      Dim strYear As String= txtYear.Text
      Dim strPurchase As String = calDate.SelectedDate.ToString
  
      Using con As OleDbConnection = New OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "DATA SOURCE=" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "App_Data", "db1.accdb"))
          Dim cmd As OleDbCommand = New OleDbCommand()
  
          cmd.CommandText = Convert.ToString("UPDATE Video_Games SET Title = @title, Console = @Console, Year_Released = @Year_Released, Purchase = @Purchase WHERE Title=" &amp; temp)
          cmd.Connection = con
  
          cmd.Parameters.AddWithValue("@Title", strTitle)
          cmd.Parameters.AddWithValue("@Console", strConsole)
          cmd.Parameters.AddWithValue("@Year_Released", strYear)
          cmd.Parameters.AddWithValue("@Purchase", strPurchase)
  
          con.Open()
  
          cmd.ExecuteNonQuery()
          con.Close()
      End Using
  
      Server.Transfer("Form.aspx", True)
  End Sub
  </code></pre>
  
  <p>I have also tried the have my where statement as: <code>WHERE Title='" &amp; temp &amp; "'")</code> Though this does not work either.</p>
  
  <p><a href="https://i.stack.imgur.com/38HHX.png" rel="nofollow noreferrer">This is the details of the Error message</a></p>