We help IT Professionals succeed at work.
Get Started

InfoPath secondary data sources

Techsavy
Techsavy asked
on
533 Views
Last Modified: 2012-08-13
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();
              }

          }
             }

Comment
Watch Question
Director of Business Integration
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE