Solved

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

Posted on 2011-02-24
3
341 Views
Last Modified: 2012-06-27
Hello,

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
                Endif
                Next
              '***************
                dt.Rows.Add(r)
                ds.WriteXml(Application.StartupPath + "\Link.xml")

Thanks,

Victor
0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
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.
0
 

Author Comment

by:vcharles
ID: 34976953
Hi,

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
                Endif
                Next

Victor
0
 
LVL 11

Accepted Solution

by:
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
Next


Next
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

635 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