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 / September 2005

Tip: Looking for answers? Try searching our database.

query & check if node was returned

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NK - 30 Sep 2005 17:13 GMT
This is a vb.net managed code. I am getting an error "Object Reference
not Set" at Line 14 where I compare if cNode is Nothing.

What this Sub does is it takes the query parameter RCTID and does a
thisXDocument.Query(), after which I want to see (compare) if a node
was returned or not. If a valid node was returned then alls ok (do not
prompt), else prompt "ID not found in the database". I have trimmed
down this code, because there is additional processing I would like to
do after this, but have to resolve this issue before proceeding ahead.

There exists an RCTID=3 in the database, I enter 3 on the query
parameter RCTID within the infopath form, hit the BTN_SEARCH button,
and infopath returns all data related to RCTID=3, but it also complains
"Object Reference not set" at Line 14.

If returned then I am assuming cNode should not be empty, but it always
gives an error, no matter if a node is retrieved or not.

Any ideas why?

1
<InfoPathEventHandler(MatchPath:="BTN_SEARCH",EventType:=InfoPathEventType.OnClick)>
_
2 Public Sub BTN_SEARCH_OnClick(ByVal e As DocActionEvent)
3     ' Write your code here.
4     Try
5  Dim qcurrRCTID
=thisXDocument.DOM.selectSingleNode("//q:Main").attributes.getNamedItem("RCTID").text
7  If (qcurrRCTID = String.Empty) Then
8      Throw New Exception("Please enter a Transfer #")
9  ElseIf (Integer.Parse(qcurrRCTID) <= 0) Then
10      Throw New Exception("Please enter a Numeric ID")
11  Else
12      thisXDocument.Query()
13      Dim cNode As IXMLDOMNode
=thisXDocument.DOM.selectSingleNode("//d:Main/")
14      If cNode Is Nothing Then
15   Throw New Exception("ID not found in thedatabase")
16      End If
17  End If
18     Catch eX As Exception
19  thisXDocument.UI.Alert(eX.Message)
20     End Try
21 End Sub
Franck Dauché - 30 Sep 2005 20:09 GMT
Hi,

Have you tried to remove the final "/"?  Also, is your prefix d or q?

Franck Dauché

> This is a vb.net managed code. I am getting an error "Object Reference
> not Set" at Line 14 where I compare if cNode is Nothing.
[quoted text clipped - 40 lines]
> 20     End Try
> 21 End Sub
NK - 30 Sep 2005 22:58 GMT
Sorry, In the first post Line #13 should read as:

13      Dim cNode As IXMLDOMNode =
thisXDocument.DOM.selectSingleNode("//d:Main")

So I cranked up the debugger, and as the form was executing I watched
"cNode", well guess what the cNode contains the correct xml structure
including data.

To search the system, prefix is "q" as we are searching a parameter
from the query, when the query is executed, results are in the
parameter "d", and I am checking if //d:Main contains anything.

It is working correctly now.

Thanks,
NK

> Hi,
>
[quoted text clipped - 46 lines]
> > 20     End Try
> > 21 End Sub

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.