title: Updating database via Gridview manually ASP.NET (VB)
body: <pre><code>Protected Sub GridView1_RowCommand _
  (sender As Object, e As GridViewCommandEventArgs) _
      Handles GridView1.RowCommand
      If e.CommandName.CompareTo("command") = 0 Then
  
          Dim itemID As Integer = Convert.ToInt32( _
              GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)
  
          Dim sqlConn As New SqlConnection("connectionString")
  
          sqlConn.Open()
  
          Dim sqlComm As New SqlCommand("UPDATE itemTable SET property = (property + 1) WHERE id = '" + itemID + "', sqlConn")
          sqlComm.ExecuteNonQuery()
  
          sqlConn.Close()
      End If
  
  End Sub
  </code></pre>
  
  <p>Basically, it doesn't work and I don't get it. I've been trying to figure this out for a few days now and I can't see what I've done wrong. As you can see I'm trying to manually update a field in my database with the value of (originalvalue)+1 when the user clicks the buttonfield of the corresponding row.</p>
  
  <p>I guess what I'm asking is if anyone can point out any mistakes, please do, or if there's a better way to do this (without having to go through all the DAL/BLL BS) please tell it to me.</p>
  
  <p>Thank you very much!</p>