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 / August 2007

Tip: Looking for answers? Try searching our database.

Object reference not set to an instance of an object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
swathi - 06 Aug 2007 13:18 GMT
Hi,
I am trying to connect to the db from infopath form through code.I wrote the
following code.
DataSource dscustomer = this.DataSources["CustomerNextNumber"];
               XPathNavigator xnCustomer = dsCustomer.CreateNavigator();
               XPathNavigator CustID =
xnCustomer.SelectSingleNode("/dfs:myFields/dfs:queryFields/d:CustomerNextNumber/d:CustID", NamespaceManager);
               string strCustID = CustID.Value; // Read
               CustID.SetValue(strApqpNbr);

At runtime, I am getting the NullReference Exception as follows.
"Object reference not set to an instance of an object"

How to resolve this.
Thanks
swathi - 06 Aug 2007 13:32 GMT
sorry, in last line it is strCustID.

CustID.SetValue(strCustID);

> Hi,
> I am trying to connect to the db from infopath form through code.I wrote the
[quoted text clipped - 11 lines]
> How to resolve this.
> Thanks
David Dean - 07 Aug 2007 03:20 GMT
There's no way to tell for sure from your code, but the null object reference
is probably occurring on the CustID variable because of a failure in
resolving the XPath expression. This may possibly be due to a case mismatch
or to using a different namespace prefix than InfoPath is expecting.

To double-check the XPath expression, go to the Data Sources pane, select
your CustomerNextNumber data source, expand the nodes to show your CustID
field, then select the "Copy XPath" option from the field's dropdown menu.
Then paste it into your code and compare.

Signature

David Dean
Sr. Member Technical Staff
Insource Technology Corp.

> sorry, in last line it is strCustID.
>
[quoted text clipped - 15 lines]
> > How to resolve this.
> > Thanks
 
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.