Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2008

Tip: Looking for answers? Try searching our database.

Programmatically Query Secondary Data Connections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kalpana - 04 Mar 2008 21:51 GMT
Hi All

I have used this code in Infopath 2003 and it would work ok but when i use
the same in Infopath 2007 and if it doesn't retrieve a result it throws an
error - "Object reference not set"

If the currentuser exists in the list, it works fine.

XPathNavigator xnBS = this.DataSources["Billing
Specialist"].CreateNavigator();
string myRole = string.Empty;
myRole =
xnBS.SelectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Billing_Specialist/@BillingSpecialistEmail[../@Billing_Specialist_UserID
= '" + currentUser + "']", this.NamespaceManager).Value;

Any ideas?

Thanks for you help
Gavin McKay - 05 Mar 2008 01:29 GMT
Hello,

Might be a change in how the SelectSingleNode works with IP2007.  It uses a
different XML processor version from memory (sorry can't remember version
numbers :) so it is possible that IP2003 would return (for example) a blank
string, whereas IP2007 returns null as the result of the SelectSingleNode and
therefore errors out with "Object reference not set" when you try and access
the .Value property.

You might need to create an object that will accept the results of
SelectSingleNode, and then test if it is valid before accessing the .Value
property similar to the following:

XPathNavigator xnBS = this.DataSources["Billing
Specialist"].CreateNavigator();
string myRole = string.Empty;
object myRoleNode =
xnBS.SelectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Billing_Specialist/@BillingSpecialistEmail[../@Billing_Specialist_UserID
= '" + currentUser + "']", this.NamespaceManager);
if (myRoleNode!=null)
{
myRole = myRoleNode.Value;
}

HTH

Gavin.

> Hi All
>
[quoted text clipped - 14 lines]
>
> Thanks for you help
Kalpana - 05 Mar 2008 04:34 GMT
Thanks - that's what i did and it worked

> Hello,
>
[quoted text clipped - 42 lines]
> >
> > Thanks for you help

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.