Techsavy
asked on
InfoPath secondary data sources
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(ob ject sender, XmlEventArgs e)
{
string myNamespace = NamespaceManager.LookupNam espace("p" );
//Get Secondary Datasources
DataSource ds = DataSources["Well Data"];
//Clear any previous Rows
XPathNavigator rootNav = MainDataSource.CreateNavig ator();
XPathNodeIterator tblRows = rootNav.Select("/p:WellAss essment/p: Wells/p:We ll", NamespaceManager);
if (tblRows.Count > 0)
{
for (int i = tblRows.Count; i > 0; i--)
{
XPathNavigator repTable = MainDataSource.CreateNavig ator();
XPathNavigator repRows = repTable.SelectSingleNode( "/p:WellAs sessment/p :Wells/p:W ell[" + i + "]", NamespaceManager);
repRows.DeleteSelf();
}
}
XPathNavigator domNav = ds.CreateNavigator();
XPathNavigator agreeNav = rootNav.SelectSingleNode(" /p:WellAss essment/p: Facility/p :Agreement Number", NamespaceManager);
string agrNum = agreeNav.Value;
XPathNodeIterator rows = domNav.Select("/dfs:myFiel ds/dfs:dat aFields/df s:Well_Dat a[@Agreeme nt_Number= '" + agrNum + "']", NamespaceManager);
//Write Secondary Data to MainData Source
while (rows.MoveNext())
{
string uniqueid = rows.Current.SelectSingleN ode("@Uniq ue_Well_Id entifier", NamespaceManager).Value.To String();
string status = rows.Current.SelectSingleN ode("@Faci lity_Statu s", NamespaceManager).Value.To String();
string spuddate = rows.Current.SelectSingleN ode("@Spud _Date", NamespaceManager).Value.To String();
string product = rows.Current.SelectSingleN ode("@Prod uct", NamespaceManager).Value.To String();
using (XmlWriter writer = MainDataSource.CreateNavig ator().Sel ectSingleN ode("/p:We llAssessme nt/p:Wells ", NamespaceManager).AppendCh ild())
{
writer.WriteStartElement(" Well", myNamespace);
writer.WriteAttributeStrin g("WellID" , uniqueid);
writer.WriteAttributeStrin g("Status" , status);
writer.WriteAttributeStrin g("SpudDat e", spuddate);
writer.WriteAttributeStrin g("Product ", product);
writer.WriteEndElement();
writer.Close();
}
}
}
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(ob
{
string myNamespace = NamespaceManager.LookupNam
//Get Secondary Datasources
DataSource ds = DataSources["Well Data"];
//Clear any previous Rows
XPathNavigator rootNav = MainDataSource.CreateNavig
XPathNodeIterator tblRows = rootNav.Select("/p:WellAss
if (tblRows.Count > 0)
{
for (int i = tblRows.Count; i > 0; i--)
{
XPathNavigator repTable = MainDataSource.CreateNavig
XPathNavigator repRows = repTable.SelectSingleNode(
repRows.DeleteSelf();
}
}
XPathNavigator domNav = ds.CreateNavigator();
XPathNavigator agreeNav = rootNav.SelectSingleNode("
string agrNum = agreeNav.Value;
XPathNodeIterator rows = domNav.Select("/dfs:myFiel
//Write Secondary Data to MainData Source
while (rows.MoveNext())
{
string uniqueid = rows.Current.SelectSingleN
string status = rows.Current.SelectSingleN
string spuddate = rows.Current.SelectSingleN
string product = rows.Current.SelectSingleN
using (XmlWriter writer = MainDataSource.CreateNavig
{
writer.WriteStartElement("
writer.WriteAttributeStrin
writer.WriteAttributeStrin
writer.WriteAttributeStrin
writer.WriteAttributeStrin
writer.WriteEndElement();
writer.Close();
}
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.