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
338 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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SubQuery link 4 35
CSV How to add columns based on existing column(s)? 20 32
Access join syntax when converting to T-SQL query 4 33
Access Schema 6 24
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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