How to loop loop through a dataset to update xml file based on rows selected from a grid?


I'm trying to update a Link.xml file based on the value of an Fuze.xml file.  How do you loop through the Fuze.xml file and set the Link Files' Fuze_ID = PFuze_ID of the Fuze file where Fuze_ID of the Link File = Fuze_ID of the Fuze file? I started writing the code, but would very much appreciate your help with the proper syntax.

                Dim ds As New DataSet
                ds.ReadXml(Application.StartupPath + "\Link.xml")
                Dim dsFuze As New DataSet
                dsFuzeA.ReadXml(Application.StartupPath + "\Fuze.xml")
                Dim dt As DataTable = ds.Tables(0)
                Dim r As DataRow = dt.NewRow
                r!Link_ID = dt.Rows(dt.Rows.Count - 1)("Link_ID") + 1
                r!Fuze_ID = C1FuzeGrid.Columns(0).Value
               For ???????
                If dsFuzeA.Fuze_ID = C1FuzeGrid.Columns(0).Value then
                r!PFuze_ID = dsFuzeA.PFuzeID
                ds.WriteXml(Application.StartupPath + "\Link.xml")


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.

Here is the procedure:

1. Loop through rows in link dataset
2. Loop through rows in fuze dataset
3. Check condition for the values in link and fuze ds
4.if condition satisfies change the value in link ds
5. Again write the dataset into XML.
vcharlesAuthor Commented:

I need help with the syntax for steps 2 and 3.

               For ???????
                If dsFuzeA.Fuze_ID = C1FuzeGrid.Columns(0).Value then
                r!PFuze_ID = dsFuzeA.PFuzeID

For each drrow as datarow in dslunk.rows
For each prow as datarow in dsfuze.rows
If drrow(fuzeid) = prow(fuzeid) then
Drrow(fuzeid) = prow(pfuzeid)
Exit for ' no need to use if the if condition will be true for      multiple rows
End if


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.

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.