How to update a database based on a DataGridView on VB.net?

0

I am loading a dataset directly to a DataGridView, it has the option to edit its records (in the DataGridView), but when finished it gives the option to save the changes, my doubt is how to save only those that were modified directly to the database in a fast way, since to go through everything and compare would be slower (due to the amount of information)

    
asked by david arellano 24.01.2018 в 18:43
source

1 answer

0

This way you could do it in the CellValueChanged event, which would be executed when you change a value in the cell. This new value is sent to an update method. Also with e.RowIndex and e.ColumnIndex you get the other indices for validations.

Private Sub Grid_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Grid.CellValueChanged
Try
 If Grid.Rows.Count > 0 Then
   Dim nuevoValorCelda As Integer = CInt(Grid.CurrentRow.Cells(2).Value)
     metodoActualizacion(nuevoValorCelda)
 End If
Catch ex As Exception
 Throw
End Catch
End Sub
    
answered by 24.01.2018 / 22:50
source