title: VB.NET changes to datagridview not saved if used in DataGridView1_CellValueChanged
body: <p>I use datagridview in VB.NET</p>
  
  <p>On button1_Click() I used bellow code to save changes made in grid to DB.</p>
  
  <pre><code>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As  System.EventArgs) Handles Button1.Click
  
      Dim cb As New OleDb.OleDbCommandBuilder(Dadapter)
  
      conList.Open()
      Dadapter.Update(DSet, "myShop")
      DSet.AcceptChanges()
      conList.Close()
  
  End Sub
  </code></pre>
  
  <p>THIS WORKS FINE.</p>
  
  <p>But I need to save data when you edit cell &amp; set the focus to another cell.
  So I used code bellow.</p>
  
  <pre><code>Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
  
      Dim nColumn As Integer
      Dim nRow As Integer
  
      nRow = e.RowIndex
      nColumn = e.ColumnIndex
  
      If Not IsDBNull(e.ColumnIndex) Then
          If e.RowIndex &gt; -1 Then
              If nColumn = 1 Then '--Column ShopName----
                  If IsDBNull(DataGridView1.Rows(e.RowIndex).Cells(1).Value) 
                                                                        Then
                      MsgBox("Shop Name Should not be Empty.")
                  Else
                      Dim cb As New OleDb.OleDbCommandBuilder(Dadapter)
  
                      conList.Open()
                      Dadapter.Update(DSet, "myShop")
                      DSet.AcceptChanges()
                      conList.Close()
                  End If
              End If
  
          End If
  
      End If
  
  End Sub
  </code></pre>
  
  <p>But data are not saved. Can anyone help me?</p>