1
Answer

Updating database with datatable

Hi guys

little help here, im creating a small application but i'm stuck on the following:
I've got a datatable that takes the data out of my db and put int in Datagridview
now once there i want to change it and update the database fields with the new values.

how do I do that?

this is what im trying to do

[code] rs = New ADODB.Recordset
        sSQL = ("Select * from [Main] where Nome = '" & linha("Nome") & "'")
        rs.ActiveConnection = cn
        rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        rs.CursorType = ADODB.CursorTypeEnum.adOpenDynamic
        rs.LockType = ADODB.LockTypeEnum.adLockOptimistic
        rs.Open(sSQL)
        With rs
            If Not .EOF Then
                For Each row As DataGridViewRow In dgv.Rows
                    .s()
                    .Fields("Morada").Value = Val(.Fields("Morada").Value) - Val(linha("Morada"))
                    .UpdateBatch(ADODB.AffectEnum.adAffectAll)
                Next
 [icode]
Answers (1)