Sql Update

Hi Experts
I use the following code to change some fields

        DA.Fill(DS, "Codes")
    count = grid3.Rows.Count
            For X = 1 To 30 - count
                Dim newCustomersRow As DataRow = DS.Tables("Codes").NewRow()
                newCustomersRow("Prefix") = "M"
                newCustomersRow("a3") = GroupBox.Text
                newCustomersRow("a10") = "@" + GroupBox.Text + "@@"
                newCustomersRow("KeyCode") = KeycodeMax.Text + X
                newCustomersRow("SubKey1") = "0"
          dt = DS.Tables("codes")
            dt.DefaultView.RowFilter = "a3 ='" & GroupBox.Text & "'"
            grid1.DataSource = dt
When I use foloowing code to update
            cmdBuilder = New SqlCommandBuilder(DA)
            DA.Update(DS, "Codes")
            MsgBox("Changes Saved")

It updates all the rows from Grid1 except the first row, where the pointer is.
If I move the pointer in the grid1 to second row then Update,     it updates all the rows.
I would like to update all the rows without moving the pointer in the grid1.
Please help
Who is Participating?
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.

You are only inserting rows right? Do you mean it does not insert the first added row?
b001Author Commented:
HI CodeCruiser:
I only insert rows if the count is less than 30.
The first row is always exist.
It does not update if the pointer is on the first row in the grid.
>I only insert rows if the count is less than 30.

>It does not update

Do you change some values as well? Programmatically?
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

b001Author Commented:
Yes . I do make changes to all rows Programmtically.
Hmm. You can change the selectedindex of the grid programmatically as well. Try with that and see if it updates the changes.
b001Author Commented:
Hi CodeCruiser:
Please write the code for me.
Grid1.SelectedIndex = 1
b001Author Commented:
I have the following error

'SelectedIndex'  is not a not a member of 'System.Windows.Forms.DataGridView'
Grid1.CurrentCell = Grid1.Item(0, 1)

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
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.