datagridview & mysql updating error

I am using below code to update mysql view through datagridview

For Each row1 As DataGridViewRow In DataGridView2.Rows

                            If Not row1.IsNewRow Then
                                DataGridView2.CurrentCell = DataGridView2(0, ii)

                                    DataGridView2(2, ii).Value = intCaja

                                ii = ii + 1

                            End If

                            da1.Update(ds1, "data")

Open in new window

This code working very well, except that it updates all records except the last record only, although I see it updated in the datagridview

I have tried to refresh the datagrid or use it's update method, without any luck
F.Y.I: this may ssems very simple for the professionals, but  I tried on this for several hours on google without any luck,. also I have pasted only a few lines of the code, which includes huge lines.

Thanks in advance for your help
Tony PeterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tony PeterAuthor Commented:
I found the answer,

Just be sure to add below line before

Open in new window


DataGridView2.CurrentCell = Nothing

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.