Problem Looping through dataset

I am trying to loop through a dataset to read its data and write it elsewhere but it does not seem that I am moving to the next record in the dataset I am reading from.  here is my code

   For Each dr As DataRow In ds.Tables("search_result").Rows

            Dim drRow As Data.DataRow = dsGrid.Tables(0).NewRow

            drRow("AAA") = ds.Tables("search_result").Rows(0).Item("ZZZ").ToString
            dsGrid.Tables(0).Rows.Add(drRow)

        Next dr

ds.Tables("search_result"). is the dataset I am reading from.

Please help.   I must be missing something
Mike_StevensAsked:
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.

Robert SchuttSoftware EngineerCommented:
Change this line
drRow("AAA") = ds.Tables("search_result").Rows(0).Item("ZZZ").ToString

Open in new window

to:
drRow("AAA") = dr.Item("ZZZ").ToString

Open in new window

dr being the loop variable, with your current code you are indeed copying from row 0 every time so in a sense 'not moving forward'.
0

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
Mike_StevensAuthor Commented:
Thanks Robert.... I  had a feeling I was missing something like that.

Thanks
0
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
Microsoft Development

From novice to tech pro — start learning today.