Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
342 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

721 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