title: DataGridView : Update SQL Database when cell value changed
body: <p>I have created a form which contains DataGridView and have created first column as checkbox column and fullrowselect is True.<br>
  I want like when I click the checkbox of the row or change the checkbox value of the selected row, that particular record should be updated in the database...</p>
  
  <p>I wrote the query properly but facing some problems mentioned below.</p>
  
  <p>Now I first tried in cell click event...<br></p>
  
  <pre><code> Private Sub DGVHelp_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGVHelp.CellClick
      Try
          If PubHelpCode = "ACTMAST" And e.ColumnIndex = 0 Then 'if only checkbox column is clicked
              cmd = New SqlCommand("Update FAMPAR SET Tag = '" &amp; DGVHelp(0, e.RowIndex).Value &amp; "' where Account_Code = '" &amp; DGVHelp(1, e.RowIndex).Value &amp; "' ", con1)
              ExecuteQuery(con1, "EDITCHECKBOX") ' Its my UDF
              DGV_Reset()' This clears the datagrid and fetch the data again
          End If
      Catch ex As Exception
          MsgBox(ex.ToString)
      End Try
  End Sub
  </code></pre>
  
  <p>When I click the checkbox cell (First column), the event first runs and then the value of the cell is changed... i.e during cellclick event, the DGVHelp(0, e.RowIndex).Value doesn't change its value if its ticked or unticked.</p>
  
  <p>I even tried cellvaluechanged event but it hanged the program by some continuous process that I don't know...</p>
  
  <p>Which event should I use to complete my task??<br></p>
  
  <p>If any other opinion/idea relating to this task is there then please share...</p>
  
  <p>The Code OneDrive link shared below..<br>
  <a href="https://1drv.ms/t/s!AlEp4GyzKDzFiL8zTA6pwIV_2my9Eg" rel="nofollow noreferrer">Solution Code link</a></p>