<?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>Multiple Selection List Box Problem with SQL table storing and retrieving</title><link>https://www.infopathdev.com:443/forums/thread/96458.aspx</link><pubDate>Fri, 14 Mar 2014 18:34:57 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:96458</guid><dc:creator>anoorula</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/96458.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=47&amp;PostID=96458</wfw:commentRss><description>Hi, 

I have been facing this problem for a long time and I hope someone could help me

1. I have a multiple selection list box whose values come from a sql table with a secondary data source Eg let us say there is a list of courses taken by a student like Mathematics, Science etc 

2. Now I have a save button with which I want to save the selection made for each student 

3. I have a output table (Student name and subject)  and a procedure in sql to save the list of choices I made for each student

4.  I was not sure how to save the choices selected for each student directly, so I convert them as a string in another text box in infopath and use this to save the choices made for a student to the table 

5. I believe since I store it as a string from the text box instead of storing directly from the multiple select list box I am not able to retrieve the values back when I want to see again what were the subjects a student was enrolled earlier


Could some one help me to find how I can directly store multiple select list box value into a sql table and how I can retreive them again from the table to see what choices were made early. 



Below is my current code

            XPathNavigator dom = MainDataSource.CreateNavigator();
            string StudentName = dom.SelectSingleNode(&amp;quot;/my:myFields/my:CompanySnapshot/my:StudentName&amp;quot;, NamespaceManager).Value;
            string Subject = dom.SelectSingleNode(&amp;quot;/my:myFields/my:TaxBusinessProcess/my:Subjecttextbox&amp;quot;, NamespaceManager).Value;  // this comes from the text  box which converts selected choices into a string this needs to change 
            
            AdoQueryConnection connection = (AdoQueryConnection)DataConnections[&amp;quot;Subject Choice&amp;quot;];

            // Save the original statement that is stored in the Command property
            string originalCommand = connection.Command;

            // Execute the stored procedure
            connection.Command = &amp;quot;EXEC SubjectProc&amp;#39;&amp;quot; + StudentName + &amp;quot;&amp;#39;,&amp;#39;&amp;quot; + Subject + &amp;quot;&amp;#39;&amp;quot;;
            connection.Execute();

            // Restore the statement of the Command property to its original value
            connection.Command = originalCommand;</description></item></channel></rss>