<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8772.aspx</link><pubDate>Thu, 12 Jan 2006 01:46:24 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8772</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8772.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8772</wfw:commentRss><description>To get the count of the number of records returned you could do this (substitute obj for XDocument if necessary):&lt;br /&gt;&lt;br /&gt;var recordsReturned = XDocument.DOM.selectNodes( "//dfs:myFields/dfs:dataFields/d:VendorList" );&lt;br /&gt;var numberOfRecords = recordsReturned.length;&lt;br /&gt;&lt;br /&gt;For an easier way to get at the fields there are a couple shortcuts. Check out this tutorial for more effecient XPath:&lt;a target="_blank" href=http://www.w3schools.com/xpath/default.asp&gt;http://www.w3schools.com/xpath/default.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Or you could use variables for commonly used XPath, like this:&lt;br /&gt;&lt;br /&gt;var XP_vendlist = "/dfs:myFields/dfs:dataFields/d:VendorList/";&lt;br /&gt;var node1 = obj.DOM.selectSingleNode( XP_vendlist + "@name" );&lt;br /&gt;&lt;br /&gt;Hope this helps, let us know if you have any more questions!&lt;br /&gt;&lt;br /&gt;---------------&lt;br /&gt;Matt Faus&lt;br /&gt;InfoPath Dev Texas&lt;br /&gt;</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8771.aspx</link><pubDate>Wed, 11 Jan 2006 22:07:19 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8771</guid><dc:creator>Lewis68</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8771.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8771</wfw:commentRss><description>Ok, I believe I got it working. Thanks.&lt;br /&gt;&lt;br /&gt;Two more questions:&lt;br /&gt;&lt;br /&gt;How do I get a count of how many records are returned?&lt;br /&gt;&lt;br /&gt;Also, is there an easier way to get at the fields then this? Maybe through the adoAdapter object? If not that's ok. I was just wondering.&lt;br /&gt;&lt;font color="blue"&gt;&lt;br /&gt;var node1 = obj.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorList/@name");&lt;br /&gt;var node2 = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorSelect/@name");&lt;br /&gt;node2.text = node1.text;&lt;br /&gt;&lt;/font id="blue"&gt;&lt;br /&gt;</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8770.aspx</link><pubDate>Wed, 11 Jan 2006 21:16:11 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8770</guid><dc:creator>Agni Jonnalagadda</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8770.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8770</wfw:commentRss><description>When you take a secondary dataconnection to DB you won't have queryFields. You will just have dataFields. This node will contain the rows returned by your DB.&lt;br /&gt;&lt;br /&gt;Starting from your redline to "obj.Query();" should be replaced with the following lines of code&lt;br /&gt;&lt;br /&gt;var adoAdapter = thisXDocument.DataObjects["asdd"].QueryAdapter;&lt;br /&gt;//Below you should have your sql query&lt;br /&gt;adoAdapter.Command = "select * from VendorList where number = " + r;&lt;br /&gt;adoAdapter.Query();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Agni&lt;br /&gt;InfoPath Dev India</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8769.aspx</link><pubDate>Wed, 11 Jan 2006 18:32:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8769</guid><dc:creator>Lewis68</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8769.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8769</wfw:commentRss><description>Well I thought I had it working.&lt;br /&gt;&lt;br /&gt;It only returns the first record in the table, regardless of the Vendor Number I use to query.&lt;br /&gt;&lt;br /&gt;Also, when I add the Second Data Source(VendorList) to the form, and it asks if you want to Submit, or Retrieve data, I specify Retrieve. But in the Data Sources view the second data source structure is "myFields/dataFields/d:VendorList". Shouldn't it be "myFields/queryFields/q:VendorList"?&lt;br /&gt;&lt;br /&gt;I tried the red line in place of the green, but then I get a (Null) error on the node line.&lt;br /&gt;&lt;br /&gt;I'm stumped. Any idea's?&lt;br /&gt;&lt;br /&gt;Below is the code.&lt;br /&gt;&lt;br /&gt;&lt;font color="blue"&gt;&lt;br /&gt;var node = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorSelect/@vendor");&lt;br /&gt;var r = node.text;&lt;br /&gt;&lt;br /&gt;var obj = XDocument.DataObjects("VendorList");&lt;br /&gt;obj.DOM.setProperty("SelectionNamespaces", 'xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-12-26T21:32:32"');&lt;br /&gt;&lt;br /&gt;&lt;font color="red"&gt;var node = obj.DOM.selectSingleNode("//dfs:myFields/dfs:queryFields/q:VendorList/@number");&lt;/font id="red"&gt;&lt;br /&gt;&lt;font color="green"&gt;var node = obj.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorList/@number");&lt;/font id="green"&gt;&lt;br /&gt;node.text = r;&lt;br /&gt;&lt;br /&gt;obj.Query();&lt;br /&gt;	&lt;br /&gt;var node = obj.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorList/@name");&lt;br /&gt;var r = node.text;&lt;br /&gt;&lt;br /&gt;var node = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorSelect/@name");&lt;br /&gt;node.text = r;&lt;br /&gt;&lt;/font id="blue"&gt;</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8768.aspx</link><pubDate>Wed, 11 Jan 2006 17:46:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8768</guid><dc:creator>Lewis68</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8768.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8768</wfw:commentRss><description>Hi Agni,&lt;br /&gt;&lt;br /&gt;I got it working. Thanks for your help.&lt;br /&gt;&lt;br /&gt;Not exactly intuitive though. Am I the only one having problems with these simple tasks? I don't think I had this much trouble when I started in the industry 15 years ago programming in C/C++.&lt;br /&gt;&lt;br /&gt;Lewis&lt;br /&gt;</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8767.aspx</link><pubDate>Wed, 11 Jan 2006 09:31:02 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8767</guid><dc:creator>Agni Jonnalagadda</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8767.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8767</wfw:commentRss><description>Hi Lewis, &lt;br /&gt;You need to do setProperty of namespaces on your obj.DOM. Namespace is something which is prefixed before the node.&lt;br /&gt;For ex: &lt;br /&gt;obj.DOM.setProperty("SelectionNamespaces", "xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" xmlns:d=\"http://tempuri.org/\"");&lt;br /&gt;&lt;br /&gt;Agni&lt;br /&gt;InfoPath Dev India</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8766.aspx</link><pubDate>Wed, 11 Jan 2006 08:12:12 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8766</guid><dc:creator>Lewis68</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8766.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8766</wfw:commentRss><description>Hi Patrick,&lt;br /&gt;&lt;br /&gt;Can you give me a link that talks about this?&lt;br /&gt;&lt;br /&gt;I'm sure this has been talked about before, but I havn't been able to find it.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br /&gt;</description></item><item><title>Re: Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/8765.aspx</link><pubDate>Wed, 11 Jan 2006 03:47:22 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:8765</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/8765.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=8765</wfw:commentRss><description>Hi Lewis,&lt;br /&gt;This is an often discussed issue. Search the forum. You need to add the namespace first.&lt;br /&gt;&lt;br /&gt;Patrick Halstead [InfoPath MVP]&lt;br /&gt;InfoPathDev</description></item><item><title>Query a Secondary Data Source</title><link>https://www.infopathdev.com:443/forums/thread/5258.aspx</link><pubDate>Tue, 10 Jan 2006 23:48:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:5258</guid><dc:creator>Lewis68</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/5258.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=5258</wfw:commentRss><description>I have a Secondary Data Source (VendorList) that I want to query and return a record with some fields, but I'm having trouble accessing the fields.&lt;br /&gt;&lt;br /&gt;I need a lookup field based on the Vendor Number. When they leave the field, I want it to lookup the 2nd data source for the Name, Address etc. and populate fields in the main data source.&lt;br /&gt;&lt;br /&gt;Below is the source in the OnAfterChange Event of the Vendor Number.&lt;br /&gt;But it errors on the red line saying "Reference to undeclared namespace prefix: dfs". I've tried every XPath I can think of, but I still can't access it. If I remove the dfs prefixes, I get null object errors.&lt;br /&gt;&lt;br /&gt;Any idea's what I'm doing wrong? Also, is there an easy way to figure out what the XPath should be for fields?&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br /&gt;&lt;font color="blue"&gt;&lt;br /&gt;var node = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorSelect/@vendor");&lt;br /&gt;var r = node.text;&lt;br /&gt;&lt;br /&gt;var obj = XDocument.DataObjects("VendorList");&lt;br /&gt;&lt;font color="red"&gt;var node = obj.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorList/@number");&lt;/font id="red"&gt;&lt;br /&gt;node.text = r;&lt;br /&gt;&lt;br /&gt;obj.DOM.Query();&lt;br /&gt;	&lt;br /&gt;&lt;font color="red"&gt;var node = obj.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorList/@name");&lt;/font id="red"&gt;&lt;br /&gt;var r = node.text;&lt;br /&gt;&lt;br /&gt;var node = XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:dataFields/d:VendorSelect/@name&lt;br /&gt;node.text = r;&lt;br /&gt;&lt;/font id="blue"&gt;</description></item></channel></rss>