I use Visual Basic 2008
I use bound Datagridview
I use mysql database

If i run this code, everything on the screen ( in the datagridview) neatly Updated.
But when I look at records in the table "stock" always the first row (0) of the DataGridView not updated in the table "stock" !
All the other record are updated with where in the datagridview!

This always happens!!!

How can fix it?

myAdapter2.SelectCommand = myCommand2
MyBuilder2 = New MySql.Data.MySqlClient.MySqlCommandBuilder(myAdapter2)
MyAdapter2.Fill(MyDataset2, "stock")
MyDataTable2 = MyDataset2.Tables("stock")

 Dim r as integer = 0
For Each Me.MyDataRow2 In MyDataTable2.Rows()
            ViewStock.Item("instock", r).Value() = 1
            r = r + 1


 Dim RowsAffectedModified2 As Integer
        If MyDataset2.HasChanges(DataRowState.Modified) Then
            RowsAffectedModified2 = myAdapter2.Update(MyDataTable2.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))
            RowsAffectedModified2 = 0
        End If
This question has already been answered. Start a new discussion instead.