<?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: Problems with a repeating table:</title><link>https://www.infopathdev.com:443/forums/thread/14961.aspx</link><pubDate>Thu, 21 Dec 2006 19:04:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14961</guid><dc:creator>DuneBug</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14961.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14961</wfw:commentRss><description>&lt;b&gt;&lt;font color="green"&gt;'Code to traverse Table and append to a string:&lt;/font id="green"&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Dim oNodeList As IXMLDOMNodeList&lt;br /&gt;Dim oNode As IXMLDOMNode&lt;br /&gt;Dim item As IXMLDOMNode&lt;br /&gt;Dim output As String&lt;br /&gt;Dim xpath As String = "dfs:myFields/dfs:dataFields/d:table/d:foreignkeytable"&lt;br /&gt;Dim k As Int16 = 0&lt;br /&gt;&lt;br /&gt;oNodeList = thisXDocument.DOM.selectNodes(xpath)&lt;br /&gt;&lt;br /&gt;If (oNodeList.length &amp;gt; 0) Then&lt;br /&gt;    &lt;font color="blue"&gt;For Each&lt;/font id="blue"&gt; oNode In oNodeList&lt;br /&gt;       output &amp;= k &amp; " = "&lt;br /&gt;       &lt;font color="blue"&gt;For Each&lt;/font id="blue"&gt; item In oNode.attributes&lt;br /&gt;           output &amp;= "{"&amp; item.nodeName &amp; " : " &amp; item.text &amp; "}" &lt;br /&gt;       &lt;font color="blue"&gt;Next&lt;br /&gt;          output &amp;= vbcrlf&lt;br /&gt;          Next&lt;/font id="blue"&gt;&lt;br /&gt;    MsgBox(output)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;&lt;font color="green"&gt;This is pretty straightforward code, and it traverses a repeating table fine. The data fields are stored by infopath in attributes instead of nodes. Here's an example, taken from my template.xml file&lt;/font id="green"&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="purple"&gt;&amp;lt;dfs:myFields (scheme goes here but i deleted it to save space.&amp;gt;&lt;br /&gt;	&amp;lt;dfs:dataFields&amp;gt;&lt;br /&gt;		&amp;lt;d:table ID="" ACCOUNTNO="" RECID=""&amp;gt;&lt;br /&gt;			&amp;lt;d:foreignkeytable ID="" Field1="" Field2="" Field3="" Field4="" Field5=""&amp;gt;&amp;lt;/d:foreignkeytable&amp;gt;&lt;br /&gt;		&amp;lt;/d:table&amp;gt;&lt;br /&gt;	&amp;lt;/dfs:dataFields&amp;gt;&lt;br /&gt;&amp;lt;/dfs:myFields&amp;gt;&lt;/font id="purple"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My repeating table is the collection of columns from my 'foreignkeytable' where 'ID' matches a certain number.&lt;br /&gt;N is a variable ID number.&lt;br /&gt;&lt;br /&gt;so my select statement looks like:&lt;br /&gt;"SELECT Field1, Field2, Field3, Field4, Field5 &lt;br /&gt;FROM "dbo"."foreignkeytable"&lt;br /&gt;WHERE ID = '&lt;font color="blue"&gt;N&lt;/font id="blue"&gt;'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="red"&gt;====================================================&lt;/font id="red"&gt;&lt;br /&gt;Almost everything works. The select statement works and causes the repeating table to be filled with values from the database. The repeating table alters its size accordingly. &lt;br /&gt;&lt;br /&gt;The loop to traverse works fine. I believe the output for 2 rows would look like:&lt;br /&gt;"1 {Field1 : [value]}{Field2 : [value]}{Field3 : [value]}{Field4 :  [value]}&lt;br /&gt;"2 {Field1 : [2ndrowvalue]}{Field2 :  [2ndrowvalue]}{Field3 : [2ndrowvalue]}{Field4 :  [2ndrowvalue]}&lt;br /&gt;&lt;br /&gt;The problem is:&lt;br /&gt;If say row1,Field2 was retrieved from the Database as a 'DBNULL'. The output would be:&lt;br /&gt;"1 {Field1 : [value]}}{Field3 : [value]}{Field4 :  [value]}&lt;br /&gt;"2 {Field1 : [2ndrowvalue]}{Field2 : [2ndrowvalue]}{Field3 : [2ndrowvalue]}{Field4 :  [2ndrowvalue]}&lt;br /&gt;&lt;br /&gt;Notice Field2 isn't there. Why?&lt;br /&gt;Well the for each loop obviously isn't seeing the Field2 node from the collection. &lt;br /&gt;I tried replacing the for each loop with a for k = 0 to attributes.length - 1 and Field2 still did not show up.&lt;br /&gt;&lt;br /&gt;I also tried changing the value of Field2 in my Infopath form to something else, but Field2 was not displayed.&lt;br /&gt;Then I tried changing the value in my DataBase table to just blank "". &lt;br /&gt;I closed and reopened the form, (which ran my select statement again) and then ran my traversal loop, And it DID output Field2 this time. &lt;br /&gt;&lt;br /&gt;And it's not just field2, if any node has DBNULL it won't show up.&lt;br /&gt;&lt;br /&gt;My guess is, since repeating tables are created dynamically, when a DBNULL is retrieved from the database there is no node created. &lt;br /&gt;This implies that infopath creates it's nodes individually and then adds them to a row, instead of creating a whole row and then filling the nodes.&lt;br /&gt;&lt;br /&gt;&lt;font color="purple"&gt;Most importantly, I was hoping there was a function that would update the node structure based on what fields were filled in the open Form. Know of any functions like this? If not I can't really think of any other solutions. I just plan to initialize all my Database fields blank strings instead of allowing them to be NULL. &lt;/font id="purple"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Also if you want to try this out:&lt;br /&gt;-Create a table in a database, i'm using MS-SQL server... Access should probably be the same.&lt;br /&gt;-Connect your infopath form to the database, create a repeating table.&lt;br /&gt;-Run some sort of select statement so that the table gets filled.&lt;br /&gt;-Traverse the table with my loop and look at the output. &lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: Problems with a repeating table:</title><link>https://www.infopathdev.com:443/forums/thread/14960.aspx</link><pubDate>Thu, 21 Dec 2006 15:53:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14960</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14960.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14960</wfw:commentRss><description>Hey Mike and welcome to the forum!&lt;br /&gt;&lt;br /&gt;I don't quite understand this problem - do you think you could paste the code here so we could look at it?  Also - you might want to use SelectNodes instead of a loop with SelectSingleNode() as it sounds like you're doing.</description></item><item><title>Problems with a repeating table:</title><link>https://www.infopathdev.com:443/forums/thread/13007.aspx</link><pubDate>Fri, 15 Dec 2006 15:52:30 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13007</guid><dc:creator>DuneBug</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13007.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13007</wfw:commentRss><description>First off: I'm running IP2003 with VS.net 2003&lt;br /&gt;&lt;br /&gt;I have a repeating table bound to a table in my Main Data Connection.&lt;br /&gt;I created a custom select statement that gets all the rows where id = N. &lt;br /&gt;The select statement works, and the fields fill auto-magically.&lt;br /&gt;&lt;br /&gt;The problem comes when I try to read these fields with code:&lt;br /&gt;Fields that have an empty string or have data are found fine. Any field that received a DBNULL from the database is not found by my loop. Also if I change the field that was DBNULL to something else, it is still not found by my loop. &lt;br /&gt;&lt;br /&gt;I'm guessing that since repeating table fields are created dynamically, when a DBNULL is received the field is not created.&lt;br /&gt;If I had to, I could just make it so when a row is inserted into the DB table all the values are set to blank instead of DBNULL, but I'd rather not do that. &lt;br /&gt;&lt;br /&gt;any suggestions? I was hoping there'd be a method i could call that would just update the XML structures.</description></item></channel></rss>