<?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>SQL Database Integration</title><link>https://www.infopathdev.com:443/forums/47.aspx</link><description>For questions concerning issues in the integration of SQL and Microsoft InfoPath.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108413.aspx</link><pubDate>Wed, 02 Nov 2016 16:36:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108413</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108413.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108413</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Sorry, I should have seen that. You need to use the full path to the production_record group &lt;strong&gt;here &lt;/strong&gt;- right click the field in the fields taskpane and select copy XPath.&lt;/p&gt;&lt;p&gt;MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;&lt;strong&gt;FULLPATHTOPRODUCTION_RECORD&lt;/strong&gt;&amp;quot;,&amp;nbsp;NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());&lt;/p&gt;</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108406.aspx</link><pubDate>Tue, 01 Nov 2016 23:54:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108406</guid><dc:creator>kee81</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108406.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108406</wfw:commentRss><description>Oops, I originally had it as d:production_items. I was trying stuff out and forgot to change it back. I changed the bottom to try to append to d:production_record, but that&amp;#39;s not working either. The final append line is throwing up a null reference exception. I&amp;#39;m doing something wrong in that statement and I&amp;#39;m not sure what.</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108400.aspx</link><pubDate>Tue, 01 Nov 2016 22:17:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108400</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108400.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108400</wfw:commentRss><description>Hmmm. A couple of things I notice in your &amp;quot;AddItem&amp;quot; method - you are starting with q:production_items - don&amp;#39;t you want &amp;quot;d&amp;quot; instead of &amp;quot;q&amp;quot;? Then, at the end, you are using append child, after selecting d:production_items, but looking at your data source, don&amp;#39;t you want to be appending this new child to d:production_record?</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108391.aspx</link><pubDate>Tue, 01 Nov 2016 17:15:29 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108391</guid><dc:creator>kee81</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108391.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108391</wfw:commentRss><description>Help! :)

So here&amp;#39;s my code, and an attached picture of my data sources. I was essentially trying to follow what was going on here: http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm

Again, the goal is to copy the data from the secondary source to the main data source.

&lt;pre&gt;
private void AddItem(string po_number, string qty_on_po, string line, string description, string start_box,
            string end_box, string parts_per_box, string run_time, string setup_time, string comments)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode group = doc.CreateElement(&amp;quot;q:production_items&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));

            XmlNode field = doc.CreateElement(&amp;quot;PO_NUMBER&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            XmlNode node = group.AppendChild(field);
            node.InnerText = po_number;
            
            field = doc.CreateElement(&amp;quot;QTY_ON_PO&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = qty_on_po;

            field = doc.CreateElement(&amp;quot;LINE&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = line;

            field = doc.CreateElement(&amp;quot;DESCRIPTION&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = description;

            field = doc.CreateElement(&amp;quot;BOX_START&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = start_box;

            field = doc.CreateElement(&amp;quot;BOX_END&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = end_box;

            field = doc.CreateElement(&amp;quot;PARTS_PER_BOX&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = parts_per_box;
            
            field = doc.CreateElement(&amp;quot;RUN_TIME&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = run_time;

            field = doc.CreateElement(&amp;quot;SETUP_TIME&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = setup_time;

            field = doc.CreateElement(&amp;quot;COMMENTS&amp;quot;, NamespaceManager.LookupNamespace(&amp;quot;my&amp;quot;));
            node = group.AppendChild(field);
            node.InnerText = comments;
            
            doc.AppendChild(group);
            //MessageBox.Show(doc.OuterXml.ToString());

            // crashes on append
            MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;d:production_items&amp;quot;, 
                NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());

        }

        private void DeleteFirstEmptyItem()
        {
            XPathNavigator domNav = MainDataSource.CreateNavigator();

            XPathNavigator itemNav = domNav.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:production_record/d:production_items[1]&amp;quot;, NamespaceManager);
            if (itemNav != null)
                itemNav.DeleteSelf();
        } 

        public void CTRL224_7_Clicked(object sender, ClickedEventArgs e)
        {
            XPathNavigator secDSNav = DataSources[&amp;quot;last_shift_query&amp;quot;].CreateNavigator();
            
            // Retrieve the rows of the secondary data source
            XPathNodeIterator rows = secDSNav.Select(&amp;quot;/dfs:myFields/dfs:dataFields/d:previous_shift_production&amp;quot;, NamespaceManager);
            
            
            // Loop through the rows of the secondary data source and fill the repeating table
            while (rows.MoveNext())
            {
                string po_number = rows.Current.SelectSingleNode(&amp;quot;@PO_NUMBER&amp;quot;, NamespaceManager).Value;
                string qty_on_po = rows.Current.SelectSingleNode(&amp;quot;@QTY_ON_PO&amp;quot;, NamespaceManager).Value;
                string line = rows.Current.SelectSingleNode(&amp;quot;@LINE&amp;quot;, NamespaceManager).Value;
                string description = rows.Current.SelectSingleNode(&amp;quot;@DESCRIPTION&amp;quot;, NamespaceManager).Value;
                string start_box = rows.Current.SelectSingleNode(&amp;quot;@BOX_START&amp;quot;, NamespaceManager).Value;
                string end_box = rows.Current.SelectSingleNode(&amp;quot;@BOX_END&amp;quot;, NamespaceManager).Value;
                string parts_per_box = rows.Current.SelectSingleNode(&amp;quot;@PARTS_PER_BOX&amp;quot;, NamespaceManager).Value;
                string run_time = rows.Current.SelectSingleNode(&amp;quot;@RUN_TIME&amp;quot;, NamespaceManager).Value;
                if (run_time == null) {
                    run_time = &amp;quot;&amp;quot;;
                }
                string setup_time = rows.Current.SelectSingleNode(&amp;quot;@SETUP_TIME&amp;quot;, NamespaceManager).Value;
                if (setup_time == null) {
                    setup_time = &amp;quot;&amp;quot;;
                }
                string comments = rows.Current.SelectSingleNode(&amp;quot;@COMMENTS&amp;quot;, NamespaceManager).Value;
                if (comments == null) {
                    comments = &amp;quot;&amp;quot;;
                }

                // Add the item to the repeating table
                AddItem(po_number, qty_on_po, line, description, start_box, end_box, parts_per_box, run_time, setup_time, comments);
            }

            // Remove the first empty item from the repeating table
            DeleteFirstEmptyItem();
        }&lt;/pre&gt;</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108375.aspx</link><pubDate>Mon, 31 Oct 2016 14:25:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108375</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108375.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108375</wfw:commentRss><description>Post your code if you need a hand. :)</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108374.aspx</link><pubDate>Mon, 31 Oct 2016 12:37:28 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108374</guid><dc:creator>kee81</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108374.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108374</wfw:commentRss><description>The goal is to submit new data to the database based on the previous shift&amp;#39;s data. Not an update to the old record. I may not have worded that very clearly. I think you&amp;#39;re right about the code. So far I have code to loop through the secondary data source records. Having trouble getting it to copy to the main data connection. I&amp;#39;m sure I&amp;#39;ll get it soon enough! ;)</description></item><item><title>Re: Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108370.aspx</link><pubDate>Fri, 28 Oct 2016 22:22:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108370</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108370.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108370</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;So - is the goal to submit new data to the DB that has some of the same data? Or are you trying to update the last shift&amp;#39;s records?&amp;nbsp; Generally - copying data from one repeating table to another in InfoPath is going to require code (or qRules) - I don&amp;#39;t think you&amp;#39;d be able to use the default data trick with a DB bound form....&lt;/p&gt;</description></item><item><title>Pre-populating repeating section from database.</title><link>https://www.infopathdev.com:443/forums/thread/108324.aspx</link><pubDate>Tue, 25 Oct 2016 14:52:38 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:108324</guid><dc:creator>kee81</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/108324.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=108324</wfw:commentRss><description>Having some trouble figuring out how to pre-populate my repeating section in InfoPath. Here&amp;#39;s my scenario. I need to provide some production personnel with a form that lets them submit production data to the database. I have a form that has a repeating section that lets them submit whatever number of rows they need to. Each row represents the production numbers for a given part on a given shift. Often times the full production run of these parts might take several days, sometimes weeks to complete. At the end of a shift, a supervisor will look over the numbers carefully and submit them to the database via the form. Then, when the next shift&amp;#39;s supervisor opens the form, I want the last shift&amp;#39;s record rows to auto-populate in the form upon opening, so that they don&amp;#39;t have to fill in 20 rows of part numbers for parts that still have many shifts to go before the order is complete. I have the query worked out to get these &amp;quot;last shift&amp;#39;s numbers&amp;quot; records from the SQL Server, and I know InfoPath can query the server, but I can&amp;#39;t figure out how to get InfoPath to populate that repeating section based on it.

I have a main connection set up that allows me to submit the form data. I created a secondary &amp;quot;retrieve data&amp;quot; connection to query the data, but I can&amp;#39;t figure out if the query is truly working or not, or how to get that queried data to my form.

Thanks for any help or direction!</description></item></channel></rss>