Setting Namespace for Secondary Datasource in Visual Basic - InfoPath Dev
in

InfoPath Dev

Setting Namespace for Secondary Datasource in Visual Basic

Last post 08-26-2010 10:04 AM by awwilkie. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-25-2010 07:03 PM

    Setting Namespace for Secondary Datasource in Visual Basic

    Hi,

    I am trying to set the value of a secondary datasource field using this code:

    Dim emp_name = thisXDocument.GetDOM("TBL_EMPLOYEE").selectSingleNode("//dfs:myFields/dfs:dataFields/d:TBL_EMPLOYEE/@EMPLOYEE_NAME")

    I understand I need to define the namespace for the secondary datasource for this to work, but I can't find any examples for Visual Basic. I am getting the typical error about dfs not being defined. Can someone assist with the proper code for VB in this situation?

    I see this code already in my form but I think it is referring to the Main Connection.

    ' The namespace prefixes defined in this attribute must remain synchronized with

    ' those in the form definition file (.xsf).

    <InfoPathNamespace("xmlns:xsf=""http://schemas.microsoft.com/office/infopath/2003/solutionDefinition"" xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" xmlns:xd=""http://schemas.microsoft.com/office/infopath/2003"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xdUtil=""http://schemas.microsoft.com/office/infopath/2003/xslt/Util"" xmlns:xdXDocument=""http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"" xmlns:xdMath=""http://schemas.microsoft.com/office/infopath/2003/slt/Math"" xmlns:xdDate=""http://schemas.microsoft.com/office/infopath/2003/xslt/Date"" xmlns:q=""http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"" xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXS/2009-05-20T22:00:01""")> _

    Many thanks for any help,

     Andrew

  • 08-25-2010 08:08 PM In reply to

    Re: Setting Namespace for Secondary Datasource in Visual Basic

    This should do the trick: 

    Dim sds As IXMLDOMDocument2 = CType(thisXDocument.GetDOM("TBL_EMPLOYEE"), IXMLDOMDocument2)

    sds.setProperty("SelectionNamespaces", "xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields""")

    Dim emp_name As IXMLDOMNode = sds.selectSingleNode("dfs:myFields/dfs:dataFields/d:TBL_EMPLOYEE/@EMPLOYEE_NAME")

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-26-2010 09:25 AM In reply to

    Re: Setting Namespace for Secondary Datasource in Visual Basic

    Thanks Jimmy...

    I entered the code into Visual Basic and it is underlining sds.selectSingleNode. The message says the following "'selectSingleNode' is ambiguous across the inherited interfaces 'Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument' and 'Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode'.

    Any ideas what is wrong here?

     

  • 08-26-2010 10:04 AM In reply to

    Re: Setting Namespace for Secondary Datasource in Visual Basic

    Found the solution...

    changed it from IXMLDOMDocument2 to IXMLDOMDocument3 as per below 

    Dim sds As IXMLDOMDocument3 = CType(thisXDocument.GetDOM("TBL_EMPLOYEE"), IXMLDOMDocument3)

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.