tags:

views:

376

answers:

0

Greetings,

I have an InfoPath 2007 form, for which the programming for parts of the form (mostly changed events) were done in C#. I am trying to convert these to VB, but, I am having an issue with DataConnection.Execute()

The original C# code seen below:

XPathNavigator main = MainDataSource.CreateNavigator();
XPathNavigator mainStart = main.SelectSingleNode("*xPath*", NamespaceManager);
string strWO = mainStart.Value.ToString();

DataSource ds = DataSources["Discrepancies"];
XPathNavigator xnds = ds.CreateNavigator();
xnds.SelectSingleNode("*xPath*", NamespaceManager).SetValue(strWO);

DataConnection dc = ds.QueryConnection;
dc.Execute();

XPathNavigator nvgFaults = DataSources["Discrepancies"].CreateNavigator();
XPathNodeIterator faultNodes = nvgFaults.Select("*xpath*", NamespaceManager);

while (faultNodes.MoveNext())
      {
      string nodeSequence = faultNodes.Current.SelectSingleNode("ACTION_SEQUENCE", NamespaceManager).Value;
      string nodeFault = faultNodes.Current.SelectSingleNode("FAULT_NOTES", NamespaceManager).Value;
      string nodeAction = faultNodes.Current.SelectSingleNode("ACTION_NOTES", NamespaceManager).Value;

      writer.WriteStartElement("group4", myNameSpace);
      writer.WriteElementString("txtSequence", myNameSpace, nodeSequence);
      writer.WriteElementString("txtFault", myNameSpace, nodeFault);
      writer.WriteElementString("txtAction", myNameSpace, nodeAction);
      writer.WriteEndElement();
      }

Executes properly, filling my form as expected, but, the VB code, shown below, does not:

Dim main As XPathNavigator = MainDataSource.CreateNavigator()
Dim mainStart As XPathNavigator = main.SelectSingleNode("*xPath*", NamespaceManager)
Dim strWO As String = mainStart.Value.ToString

Dim dsresult As DataSource = DataSources("Discrepancies")
Dim xNav As XPathNavigator = dsresult.CreateNavigator()
xNav.SelectSingleNode("*xPath*", NamespaceManager).SetValue(strWO)

Dim dataConn As DataConnection = dsresult.QueryConnection()
dataConn.Execute()

Dim navFaults As XPathNavigator = DataSources("Discrepancies").CreateNavigator()
Dim faultNodes As XPathNodeIterator = navFaults.Select("*xPath*", NamespaceManager)

Dim myNameSpace As String = NamespaceManager.LookupNamespace("my")

While faultNodes.MoveNext()
       Dim nodeSequence As String = faultNodes.Current.SelectSingleNode("ACTION_SEQUENCE", NamespaceManager).Value
       Dim nodeFault As String = faultNodes.Current.SelectSingleNode("FAULT_NOTES", NamespaceManager).Value
       Dim nodeAction As String = faultNodes.Current.SelectSingleNode("ACTION_NOTES", NamespaceManager).Value

       Using writer As XmlWriter = MainDataSource.CreateNavigator(). _
       SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild()

              writer.WriteStartElement("group2", myNameSpace)
              writer.WriteElementString("txtSequence", myNameSpace, nodeSequence)
              writer.WriteElementString("txtFault", myNameSpace, nodeFault)
              writer.WriteElementString("txtAction", myNameSpace, nodeAction)
              writer.WriteEndElement()
              writer.Close()
        End Using
End While

I have run several tests (not illustrated in the examples) to prove that I am, in fact, getting the proper variables, such as 'strWO'. This variable is then passed to the DataSource "Discrepancies", which is a stored procedure.

If I invoke the SP Discrepancies through my WebMethod (also converted to VB), it does in fact, return the information it should. That is all well and good. I get the information that I expect.

But, the VB version, does not execute the query. Doing a simple test on node counts, I get '0.' Whereas the particular item I am testing, should return a node count in the low 40's. There is data to be had, yet, I cannot get the query to execute. And it's driving me mad.

Some of the variable names are different from c# to vb, as well as some infoPath xPaths, which I have simplified down to just xpath for readability. Some of those xPaths get pretty long. But, I am positive that any variable name changes are consistent.

Any help is appreciated.

Thanks.