Hi! I am trying to query a data connection using C#.NET in InfoPath. I have a created a data connection in InfoPath to a web service. The web service accpts two parameters SearchColumn and SearchText. I try to do this using the code listed below.
DataObject objDO = null;
objDO = thisXDocument.DataObjects["getPatient"];
IXMLDOMDocument3 domXML = (IXMLDOMDocument3) objDO.DOM;
domXML.setProperty( "SelectionNamespaces", "xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" " + "xmlns:s0=\"http://tempuri.org/\"");
IXMLDOMNode QueryInput = objDO.DOM.selectSingleNode("/s0:myFields/s0:queryFields/s0:getPatient/s0:SearchColumn" );
IXMLDOMNode RidNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:SearchGroup/my:ddlSearch");
QueryInput.text = RidNode.text;
//objDO.Query();
IXMLDOMNode QueryInput1 = objDO.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/s0:getPatient/s0:SearchText" );
IXMLDOMNode RidNode1 = thisXDocument.DOM.selectSingleNode("/my:myFields/my:SearchGroup/my:txtSearch");
QueryInput1.text = RidNode1.text;
objDO.Query();
I get a Null Reference exception when I run this query.
System.NullReferenceException
Object reference not set to an instance of an object.
at HLA.HLA.CTRL3_22_OnClick(DocActionEvent e) in c:\hla\formcode.cs:line 63
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Line 63 in the code is the place where I assign the value of query variable from secondary data source with the value from primary data source. Any suggestions of how to solve this problem.
Thanks in advance.
speddi.
speddi