<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Write an sql result inside a Textbox in infopath</title><link>https://www.infopathdev.com:443/forums/thread/105018.aspx</link><pubDate>Wed, 30 Dec 2015 16:30:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:105018</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/105018.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=105018</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;You just need to get the value for the Name field from your secondary data connection (looks like the name is &amp;quot;DBConnection&amp;quot;?) and set the value of the field you want to have the result in.&lt;/p&gt;&lt;p&gt;So, you&amp;nbsp;need the XPath to the field in&amp;nbsp;the secondary data connection (right click on it in the&amp;nbsp;Fields task pane in InfoPath and select &amp;quot;copy XPath&amp;quot;), then get the value of it:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;XPathNavigator nameField = this.DataSources[&amp;quot;DBConnection&amp;quot;].CreateNavigator().SelectSingleNode(&amp;quot;YourXPathHere&amp;quot;, NamespaceManager);&lt;br /&gt;if (null != nameField)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elemYourTextBox2.SetValue(nameField.Value);&lt;br /&gt;}&lt;/p&gt;</description></item><item><title>Write an sql result inside a Textbox in infopath</title><link>https://www.infopathdev.com:443/forums/thread/104989.aspx</link><pubDate>Wed, 23 Dec 2015 14:32:56 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:104989</guid><dc:creator>pepsilon</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/104989.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=104989</wfw:commentRss><description>OBS: Im sorry, i dont know how to format code on this website, it seems to be normal when i type it in here but not when it&amp;#39;s posted

Hi

I have 2 textfields:

Textfield 1 - the user types an input number

Textfield 2 - You get the result from what the user typed in the first textfield.

            public void Btn_Check_Clicked(object sender, ClickedEventArgs e) {
            XPathNavigator elemYourTextBox1 = this.MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;//my:Txb_1&amp;quot;, this.NamespaceManager);
            String DataFromTextField = elemYourTextBox1.Value;
            
            XPathNavigator elemYourTextBox2 = this.MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;//my:Txb_2&amp;quot;, this.NamespaceManager);
            String DataFromTextField_Result = elemYourTextBox2.Value;

            //My query string
            AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections[&amp;quot;DBConnection&amp;quot;]);
            string sql = &amp;quot;Select Distinct Name from TableUsers where ID = &amp;#39;&amp;quot; + DataFromTextField + &amp;quot;&amp;#39;&amp;quot;;
            conn.Command = sql;
            conn.Execute();
            //Here i want my result viewed once the button is clicked
            DataFromTextField_Result = Name (the result from my sql query)
            
    }

My problem is I don&amp;#39;t know how to make my sql query get the result and view it on my textfield, infopath makes it really hard for me to do clean C# code in the codebehind part</description></item></channel></rss>