troubleshooting Question

InfoPath secondary data sources

Avatar of Techsavy
Techsavy asked on
InfoPath
1 Comment1 Solution537 ViewsLast Modified:
Hi

I am writing data from main data source to secondary data source...using following Code. The secondary data source I am using is a Sharepoint List.
However, the seondary data source does not seem to refresh data.

Any ideas why this is happening?

      public void AgreementNumber_Changed(object sender, XmlEventArgs e)
      {
       string myNamespace = NamespaceManager.LookupNamespace("p");


       
          //Get Secondary Datasources

       DataSource ds = DataSources["Well Data"];

       

          //Clear any previous Rows
          XPathNavigator rootNav = MainDataSource.CreateNavigator();
       
          XPathNodeIterator tblRows = rootNav.Select("/p:WellAssessment/p:Wells/p:Well", NamespaceManager);

       
     



         if (tblRows.Count > 0)
         {

           for (int i = tblRows.Count; i > 0; i--)
             {
                 XPathNavigator repTable = MainDataSource.CreateNavigator();
                XPathNavigator repRows = repTable.SelectSingleNode("/p:WellAssessment/p:Wells/p:Well[" + i + "]", NamespaceManager);
                 repRows.DeleteSelf();
             }



         }


         


         


          XPathNavigator domNav = ds.CreateNavigator();
          XPathNavigator agreeNav = rootNav.SelectSingleNode("/p:WellAssessment/p:Facility/p:AgreementNumber", NamespaceManager);

          string agrNum = agreeNav.Value;

          XPathNodeIterator rows = domNav.Select("/dfs:myFields/dfs:dataFields/dfs:Well_Data[@Agreement_Number='" + agrNum + "']", NamespaceManager);

         


          //Write Secondary Data to MainData Source
          while (rows.MoveNext())
          {
              string uniqueid = rows.Current.SelectSingleNode("@Unique_Well_Identifier", NamespaceManager).Value.ToString();
              string status = rows.Current.SelectSingleNode("@Facility_Status", NamespaceManager).Value.ToString();
              string spuddate = rows.Current.SelectSingleNode("@Spud_Date", NamespaceManager).Value.ToString();
              string product = rows.Current.SelectSingleNode("@Product", NamespaceManager).Value.ToString();

              using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/p:WellAssessment/p:Wells", NamespaceManager).AppendChild())
              {
                  writer.WriteStartElement("Well", myNamespace);
                  writer.WriteAttributeString("WellID", uniqueid);
                  writer.WriteAttributeString("Status", status);
                  writer.WriteAttributeString("SpudDate", spuddate);
                  writer.WriteAttributeString("Product", product);
                  writer.WriteEndElement();
                  writer.Close();
              }

          }
             }

ASKER CERTIFIED SOLUTION
Clay Fox
Director of Business Integration

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros