<?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>How to execute a C# sql insert after the submit to database and close button is clicked</title><link>https://www.infopathdev.com:443/forums/thread/62830.aspx</link><pubDate>Wed, 05 Jan 2011 20:21:49 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:62830</guid><dc:creator>pauljtay</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/62830.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=62830</wfw:commentRss><description>&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;I have an InfoPath&amp;nbsp;2007 (IP)&amp;nbsp;form that is opened from a&amp;nbsp;MOSS 2007&amp;nbsp;SP site with a primary data connection to&amp;nbsp;an Access 2007&amp;nbsp;Database (BD).&amp;nbsp;When the form is opened, a&amp;nbsp;number (#)&amp;nbsp;is manually entered and the&amp;nbsp;DB is queried to see if there is an entry in the DB for that particular #.&amp;nbsp;If the query returns&amp;nbsp;&amp;quot;true&amp;quot; (the # exists in the DB), then IP&amp;nbsp;switches to the &amp;quot;Continued Form&amp;quot; view and everything works great.&amp;nbsp;If the&amp;nbsp;query returns &amp;quot;false&amp;quot; (the&amp;nbsp;# doesn&amp;#39;t exist in the DB), IP&amp;nbsp;switches to the &amp;quot;Start New Form?&amp;quot; view. Once the &amp;quot;Start New Form?&amp;quot; button is clicked, the C# code behind pulls information from multiple outside sources, opens the &amp;quot;New Form&amp;quot; view and&amp;nbsp;populates some of the fields with that information. &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;The first problem occures with IP returning a&amp;nbsp;&amp;quot;false&amp;quot; query.&amp;nbsp;Once IP recognizes the &amp;quot;false&amp;quot; return, it&amp;nbsp;fails to show&amp;nbsp;any of the&amp;nbsp;&lt;u&gt;repeating sections&lt;/u&gt; in the &amp;quot;New Form&amp;quot; view, or any view for that matter. These repeating&amp;nbsp;sections&amp;nbsp;allow the user to fill in information in the form that is then saved back to the Access DB. Without&amp;nbsp;the repeating sections the form is usless.&amp;nbsp;Through the use of rules I was able to work around this issue. That process is a follows:&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Once the &amp;quot;Query the Database&amp;quot; button is clicked and the query returns false I write the queried #&amp;nbsp;to a # holder field, set the original&amp;nbsp;# field to “0” and query the DB again. That returns the ”0” placeholder I&amp;nbsp;added to the DB which is just an empty &amp;quot;New Form&amp;quot;. I then switch the view to the &amp;quot;New Form Start Page&amp;quot; and&amp;nbsp;repopulate the&amp;nbsp;# field with the&amp;nbsp;original # that I placed in the # holder field. At this point all of the&amp;nbsp;repeating sections are available and the form is good to go.&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Unfortunately, a new problem appears once the form is submitted back to the DB and closed. &lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Since I retrieved the “0” placeholder from the&amp;nbsp;DB and populated it with&amp;nbsp;the original&amp;nbsp;#, the placeholder gets written over when the form is submitted and closed. So the next time the # query returns false there isn’t a “0” placeholder in the&amp;nbsp;DB anymore and the original problem comes back. &lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;So after all that here&amp;nbsp;are my questions.&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Is there a solution to the original problem (missing repeating sections)? If not, how do I add a new “0” placeholder into the&amp;nbsp;DB once the “Submit and Close the Checklist” button has been clicked (I&amp;#39;m pretty sure that I will need to use code behind to accomplish this)? &lt;/font&gt;&lt;font size="3" face="Calibri"&gt;Or could&amp;nbsp;the “0” placeholder be added to the&amp;nbsp;DB only after&amp;nbsp;the DB query returns &amp;quot;false&amp;quot;?&amp;nbsp;Could&lt;/font&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt; the&amp;nbsp;“0” placeholder be added to the database as soon as the form is opened as long as it doesn’t already exist?&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;I apologize for the lengthy post and thanks in advance for any help.&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>