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

Posted on 2011-02-24
Last Modified: 2012-06-27

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")


Question by:vcharles
  • 2
LVL 11

Expert Comment

ID: 34976732
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.

Author Comment

ID: 34976953

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

LVL 11

Accepted Solution

srikanthreddyn143 earned 500 total points
ID: 34979024
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


Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now