<?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>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14896.aspx</link><pubDate>Thu, 30 Nov 2006 16:13:33 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14896</guid><dc:creator>leGeneral</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14896.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14896</wfw:commentRss><description>First of all thanks Greg for you help so far!!!!!!&lt;br /&gt;&lt;br /&gt;I found a solution to copy a row. &lt;br /&gt;&lt;br /&gt;var id = eventObj.Source.selectSingleNode("@Id");&lt;br /&gt;var vk = eventObj.Source.selectSingleNode("@VK");&lt;br /&gt;nNewLocalCacheRow = nSampleProductNode.cloneNode(true); &lt;br /&gt;nNewLocalCacheRow.selectSingleNode( "@ArtikelID" ).text = parseInt(id.text);&lt;br /&gt;nNewLocalCacheRow.selectSingleNode( "@VK" ).text = vk.text;&lt;br /&gt;XDocument.DOM.selectSingleNode( "/dfs:myFields/dfs:dataFields/d:Produkte" ).appendChild( nNewLocalCacheRow );&lt;br /&gt;&lt;br /&gt;nSampleProductNode ist defined in OnLoad like this:&lt;br /&gt;nSampleProductNode = XDocument.DOM.selectSingleNode( "//d:Umsatz" );&lt;br /&gt;&lt;br /&gt;This works fine!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After I figured that out I noticed a new problem:&lt;br /&gt;&lt;br /&gt;After choosing some products I would like to update the stock of the chosen products in my sales table. So I wrote this code:&lt;br /&gt;&lt;br /&gt;I wrote a custom sql command so that a querry returns the chosen products. To avoid that after this querry my sales table is empty I copy the rows back after executing the querry. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;var selectedUms = XDocument.DOM.selectNodes("//d:Umsatz");&lt;br /&gt;var i=0;&lt;br /&gt;var sql = "SELECT * FROM Produkte WHERE Id= ";&lt;br /&gt;var sqlWhere;&lt;br /&gt;while (oSrc = selectedUms.nextNode()){	&lt;br /&gt;	var artikelID = oSrc.selectSingleNode("@ArtikelID").text;&lt;br /&gt;	if (i == 0){&lt;br /&gt;		sqlWhere = artikelID + " ";&lt;br /&gt;		sql = sql + sqlWhere;	&lt;br /&gt;	}&lt;br /&gt;	else {&lt;br /&gt;		sqlWhere = "OR Id =" + artikelID + " ";&lt;br /&gt;		sql = sql + sqlWhere;			&lt;br /&gt;	}&lt;br /&gt;	i++;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;selectedUms = XDocument.DOM.selectNodes("//d:Umsatz");&lt;br /&gt;XDocument.QueryAdapter.Command = sql;&lt;br /&gt;XDocument.Query();&lt;br /&gt;&lt;br /&gt;var UmsTab = XDocument.DOM.selectNodes("//d:Umsatz");&lt;br /&gt;UmsTab.removeAll();&lt;br /&gt;&lt;br /&gt;while (oSrc = selectedUms.nextNode()){	&lt;br /&gt;	nNewLocalCacheRow = nSampleProductNode.cloneNode(true);&lt;br /&gt;&lt;br /&gt;	nNewLocalCacheRow.selectSingleNode("@ArtikelID").text = parseInt(oSrc.selectSingleNode("@ArtikelID").text);&lt;br /&gt;	nNewLocalCacheRow.selectSingleNode("@VK").text = oSrc.selectSingleNode("@VK").text;&lt;br /&gt;	nNewLocalCacheRow.selectSingleNode("@Nachbestellen").text = oSrc.selectSingleNode("@Nachbestellen").text;&lt;br /&gt;		&lt;br /&gt;	XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Produkte").appendChild(nNewLocalCacheRow);	&lt;br /&gt;}	&lt;br /&gt;&lt;/pre&gt;	&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I looks like it works fine. But when I am trying to save the data back to my database I receive an error like: &lt;br /&gt;&lt;br /&gt;"structure of group "dataFields" has changed and is not similar to the structure of the data source"&lt;br /&gt;&lt;br /&gt;I can't see any probelm because I use a similar code to querry the data source without any error. After executing this code there is no problem to save data to my database:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;var selectedUms = XDocument.DOM.selectNodes("//d:Umsatz");&lt;br /&gt;XDocument.Query();&lt;br /&gt;&lt;br /&gt;var UmsTab = XDocument.DOM.selectNodes("//d:Umsatz");&lt;br /&gt;UmsTab.removeAll();&lt;br /&gt;	&lt;br /&gt;while (oSrc = selectedUms.nextNode()){	&lt;br /&gt;	nNewLocalCacheRow = nSampleProductNode.cloneNode(true);&lt;br /&gt;	if ((oSrc.selectSingleNode("@ArtikelID").text) != ""){&lt;br /&gt;	nNewLocalCacheRow.selectSingleNode("@ArtikelID").text = oSrc.selectSingleNode("@ArtikelID").text;&lt;br /&gt;	nNewLocalCacheRow.selectSingleNode("@VK").text = oSrc.selectSingleNode("@VK").text;			nNewLocalCacheRow.selectSingleNode("@Nachbestellen").text = oSrc.selectSingleNode("@Nachbestellen").text;			&lt;br /&gt;	XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Produkte").appendChild(nNewLocalCacheRow);	&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Christoph</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14895.aspx</link><pubDate>Fri, 17 Nov 2006 17:42:33 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14895</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14895.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14895</wfw:commentRss><description>As I look at the image of your data source, I see that you have a root node named myFields which you are not accounting for. When an XPath begins with a slash ('/'), that means to start from the root node. Since Produkte is not the root node, this will of course fail.&lt;br /&gt;&lt;br /&gt;I'm not sure what the namespace for myFields is, but let's assume that it is "my:". Then you would need to try something like:&lt;br /&gt;&lt;br /&gt;.selectSingleNode("/my:myFields");&lt;br /&gt;&lt;br /&gt;and then&lt;br /&gt;&lt;br /&gt;.selectSingleNode("/my:myFields/dfs:dataFields");&lt;br /&gt;&lt;br /&gt;and so on.</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14894.aspx</link><pubDate>Thu, 16 Nov 2006 22:08:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14894</guid><dc:creator>leGeneral</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14894.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14894</wfw:commentRss><description>var test = secondaryDOM.selectSingleNode("/dfs:myFields");&lt;br /&gt;&lt;br /&gt;-&amp;gt; It failed and returns null.&lt;br /&gt;&lt;br /&gt;I made a Screenshot of my datasource. I hope this helps a little. &lt;br /&gt;&lt;br /&gt;&lt;img src='http://irrlichter.net/sonstiges/Bilder/DS_IP.jpg' border='0' /&gt;&lt;br /&gt;&lt;br /&gt;After extracting my form I found a "Produkte.xsd" and a "Produkte1.xsd". &lt;br /&gt;&lt;br /&gt;&lt;u&gt;In "Produkte.xsd" I found this line:&lt;br /&gt;&lt;/u&gt;&lt;br /&gt;&amp;lt;xsd:schema targetNamespace="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;xsd:import schemaLocation="Produkte1.xsd" namespace="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"&amp;gt;&amp;lt;/xsd:import&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;In "Produkte1.xsd":&lt;/u&gt;&lt;br /&gt;&amp;lt;xsd:schema targetNamespace="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" elementFormDefault="unqualified" attributeFormDefault="unqualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I'm not sure if I set the namespace correct??</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14893.aspx</link><pubDate>Thu, 16 Nov 2006 17:25:02 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14893</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14893.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14893</wfw:commentRss><description>Since you are using JScript, all variables use "var". That is why when you tried to define a variable as "XDocument" it failed.&lt;br /&gt;&lt;br /&gt;Since you are getting an object back, that is a good start. But all that means is that you have a valid data connection named "Produkte".&lt;br /&gt;&lt;br /&gt;Now you need to find out where the problem is coming from. Keep in mind that you might be getting a false positive with your "var sec" test because "selectNodes" might always returns an object, even if it doesn't find anything. So first try:&lt;br /&gt;&lt;br /&gt;var test = secondaryDOM.selectSingleNode("/dfs:myFields");&lt;br /&gt;&lt;br /&gt;If that fails then there's one of two problems:&lt;br /&gt;1. dfs:myFields is not the correct A) namespace and/or B) node name.&lt;br /&gt;2. The namespace definition you supplied is not correct according to the schema of the data connection.&lt;br /&gt;&lt;br /&gt;If this doesn't fail--that's good. Keep using selectSingleNode at this point, and not selectNodes. Add on dfs:dataFields and see if that works and so on until it fails.&lt;br /&gt;&lt;br /&gt;Maybe @Id should really be @d:Id. Check for namespaces there too.</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14892.aspx</link><pubDate>Thu, 16 Nov 2006 16:41:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14892</guid><dc:creator>leGeneral</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14892.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14892</wfw:commentRss><description>I tried this:&lt;br /&gt;&lt;br /&gt;XDocument secondaryDOM = XDocument.GetDOM( "Produkte" );&lt;br /&gt;&lt;br /&gt;After opening the form I receive an error.(";" expected)&lt;br /&gt;&lt;br /&gt;So I did it like this:&lt;br /&gt;&lt;br /&gt;var secondaryDOM = XDocument.GetDOM( "Produkte" );&lt;br /&gt;&lt;br /&gt;This returns an object. &lt;br /&gt;&lt;br /&gt;After setting the namspace (like Shiva posted) I tried to select a node:&lt;br /&gt;&lt;br /&gt;var sec = secondaryDOM.selectNodes("/dfs:myFields/dfs:dataFields/d:Produkte");&lt;br /&gt;&lt;br /&gt;-&amp;gt; Returns Type: Object Value: {...}.&lt;br /&gt;&lt;br /&gt;var singleNode = secondaryDOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Produkte/@Id")&lt;br /&gt;&lt;br /&gt;-&amp;gt; Returns Type: Object Value: null.&lt;br /&gt;&lt;br /&gt;Any idea?&lt;br /&gt;</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14891.aspx</link><pubDate>Wed, 15 Nov 2006 17:44:15 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14891</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14891.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14891</wfw:commentRss><description>First verify that GetDOM is actually returning an object.&lt;br /&gt;&lt;br /&gt;Then see if you can select the root node. Then then next one down, etc.&lt;br /&gt;&lt;br /&gt;Troubleshoot this way to figure out where the source of the problem is. Find out where the selections are failing. . . is it the data source object itself, or the XPath?</description></item><item><title>Re: Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/14890.aspx</link><pubDate>Wed, 15 Nov 2006 17:44:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14890</guid><dc:creator>Shiva</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14890.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14890</wfw:commentRss><description>XDocument  secondaryDOM = XDocument.GetDOM( "Produkte" );&lt;br /&gt;//First you need to check the DOM is getting or not&lt;br /&gt;secondaryDOM.setProperty( "SelectionNamespaces" , 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution " xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');&lt;br /&gt;//Try to set the property of the namespaces&lt;br /&gt;&lt;br /&gt;var nodeText = secondaryDOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Produkte/@Id").text;&lt;br /&gt;//Try to get the node text.&lt;br /&gt;&lt;br /&gt;For each step you need to debug and let you know where is the your code is wrong. If you get the any specific error let us know.</description></item><item><title>Copy data from secondary to primary data source</title><link>https://www.infopathdev.com:443/forums/thread/12981.aspx</link><pubDate>Tue, 14 Nov 2006 21:20:10 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12981</guid><dc:creator>leGeneral</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12981.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12981</wfw:commentRss><description>Hallo,&lt;br /&gt;&lt;br /&gt;After some days of trying and searching without any result I hope someone could help me to solve my problem.&lt;br /&gt;&lt;br /&gt;First of all what I am trying to do:&lt;br /&gt;I developed a form based on an access database with a sales table. I created a secondary datasource ("Produkte") which receives data (detailed data of products) from the same database.  &lt;br /&gt;The products are bound to a repeating table. I also added a button to the repeating table, so that there is a button in every row. After clicking the button some of the products data should be copied to the  sales table (also a repeating table).&lt;br /&gt;Afterwards I want to save the rows of the sales table to the database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I don't know how I could solve this problem?&lt;br /&gt;&lt;br /&gt;After reading this post I tried it also this way:&lt;br /&gt;&lt;a href='http://infopathdev.com/forums/topic.asp?TOPIC_ID=2781&amp;SearchTerms=oFromItem,length' target='_blank' title='http://infopathdev.com/forums/topic.asp?TOPIC_ID=2781&amp;SearchTerms=oFromItem,length'&lt;a target="_blank" href=http://infopathdev.com/forums/topic.asp?TOPIC_ID=2781&amp;SearchTerms=oFromItem&gt;http://infopathdev.com/forums/topic.asp?TOPIC_ID=2781&amp;SearchTerms=oFromItem&lt;/a&gt;,length&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;var selectedNodes=XDocument.GetDOM("Produkte").selectedNodes("/dfs:myFields/dfs:dataFields/d:Produkte");&lt;br /&gt;&lt;br /&gt;selectedNodes.length is just returning "0".&lt;br /&gt;&lt;br /&gt;I also set the namespace like in the HowTo on this page:&lt;br /&gt;&lt;br /&gt;XDocument.GetDOM( "Produkte" ).setProperty( "SelectionNamespaces" , 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution " xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');&lt;br /&gt;&lt;br /&gt;I also tried a lot of variations to access the secondary datasource like:&lt;br /&gt;&lt;br /&gt;XDocument.GetDOM("Produkte").selectSingleNode("//dfs:myFields/dfs:dataFields/d:Produkte/@Id").text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I hope someone could help me cause at the moment I don't know what else to try. &lt;br /&gt;&lt;br /&gt;Christoph</description></item></channel></rss>