query & check if node was returned - InfoPath Dev
in

InfoPath Dev

query & check if node was returned

Last post 09-30-2005 09:18 AM by nkelkar. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 09-30-2005 09:18 AM

    • nkelkar
    • Not Ranked
    • Joined on 09-30-2005
    • Canada
    • Posts 11

    query & check if node was returned

    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
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.