'cannot update datagridview values

I have a vb net application connected to an sql server database, I have a datagridview to retrieve insert delete and update records. When I add a new record cannot update the record, the datagridview stays in edit mode. Here is the code, any help :

Private Sub SaveToolStripButton1_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton1.Click
    Table2BindingSource2.EndEdit()
    If DataSet31.HasChanges Then
        Try
           SqlDataAdapter2.Update(DataSet31, "Table_2")
            DataSet31.AcceptChanges()
        Catch eUpdate As System.Exception
            MsgBox(eUpdate.Message.ToString)
        End Try
    End If
End Sub


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source