Accessing nodes of secondary datasource - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Accessing nodes of secondary datasource

Last post 01-15-2009 06:08 PM by savita. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-15-2009 05:53 AM

    Accessing nodes of secondary datasource

    Hi. I went through some very informative links on namespece definitions and secondary datasources.

    I am using Infopath 2003 SP2, Access 2003 and prg language is VBScript.  I have a form where I need to access a secondary datasource named UserAccess to find the access of the user who logs in.
    The secondary  datasource looks like below:


    I have added the following namespacesDefinition in the form which I got in the properties of UserAccess.
    XDocument.GetDOM("UserAccess").setProperty "SelectionNamespaces", "xmlns:ns1="""""

     The code looks like below:

    Sub btn_Test_OnClick(eventObj)
            dim orig_sql, criteria, new_sql, user_acc
            orig_sql = XDocument.DataAdapters("UserAccess").Command
            criteria = "SNS002"                              ' hardcoding only for testing
            new_sql = orig_sql + " where userid = '" + criteria + "'"
            XDocument.DataAdapters("UserAccess").Command = new_sql
            user_acc = XDocument.getDOM("UserAccess").selectSingleNode("ns1:useracc").value
    End Sub

    The line of code where I try to access the value from useracc column throws an error 'Object required'. I have tried using:
    XDocument.getDOM("UserAccess").selectSingleNode("/ns1:@useracc").value and many other combinations but nothing helped.

    What am I doing wrong? Is the namespacesDefinition wrong?  I intend to use the same logic to check whether a user is entering duplicate data in a column which has unique key constraint.

    Please help!!

    Filed under: , ,
  • 01-15-2009 06:26 AM In reply to

    Re: Accessing nodes of secondary datasource


    Try the following code line.

    user_acc = XDocument.getDOM("UserAccess").selectSingleNode("write the total xpath of the user acc").value

    the total xpath may be like ‘myFields/ dataFields/ns1:UserAccess'

    Also once verify any prefix need to add before the myfields and dataFields.


    Or use the following one.

    user_acc = XDocument.getDOM("UserAccess").selectSingleNode("//ns1:UserAccess").value


  • 01-15-2009 06:08 PM In reply to

    Re: Accessing nodes of secondary datasource

    Hi swathip. Thanks for your help. I solved the problem.

    I had used selectSingleNode("/dfs:myFields/dfs:dataFields/d:UserAccess/@useracc").value in the beginning and many other combinations. But my namespace definition was going all wrong. I changed the namespace definition.

    XDocument.GetDOM("UserAccess").setProperty "SelectionNamespaces", "xmlns:ns1="""""

    XDocument.GetDOM("UserAccess").setProperty "SelectionNamespaces", "xmlns:d="""" xmlns:dfs="""""

    And then I could use the following to access useracc field from the secondary datasource.

    user_acc = XDocument.getDOM("UserAccess").selectSingleNode("/dfs:myFields/dfs:dataFields/d:UserAccess/@useracc").value

    Thanks again.

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