<?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>Browser Forms</title><link>https://www.infopathdev.com:443/forums/40.aspx</link><description>For browser form specific questions</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Query and Populate Drop Down via SQL C# code</title><link>https://www.infopathdev.com:443/forums/thread/79650.aspx</link><pubDate>Tue, 19 Jun 2012 15:27:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79650</guid><dc:creator>Bricey</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79650.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=40&amp;PostID=79650</wfw:commentRss><description>&lt;p&gt;Thats the ticket! - Thank you so much Hilary!&lt;/p&gt;
&lt;p&gt;I use infopath alot, but hardly ever with code. I shall make an effort to visit here often and share anything I learn!&lt;/p&gt;</description></item><item><title>Re: Query and Populate Drop Down via SQL C# code</title><link>https://www.infopathdev.com:443/forums/thread/79647.aspx</link><pubDate>Tue, 19 Jun 2012 15:11:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79647</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79647.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=40&amp;PostID=79647</wfw:commentRss><description>&lt;p&gt;Hi - the error on your query is that you don&amp;#39;t have a column named &amp;quot;SalesPersonLkup&amp;quot; in your table that you are querying - is that the case?&lt;/p&gt;
&lt;p&gt;As to your question:&lt;/p&gt;
&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/infopathdev/images/icon-quote.gif"&gt; &lt;strong&gt;Bricey:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Also, Im unsure what drop down im supposed to be populating?!&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;Well - the code should give you a populate data source - yours is named &amp;quot;FullInfo&amp;quot;. Then you would have a drop down on your form that uses this for its list items? But you could also use the data in other ways. Drag the data fields from the FullInfo data source onto your form while you are working so you can see what is being returned once you get your code error addressed.&lt;/p&gt;</description></item><item><title>Query and Populate Drop Down via SQL C# code</title><link>https://www.infopathdev.com:443/forums/thread/79634.aspx</link><pubDate>Tue, 19 Jun 2012 10:06:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79634</guid><dc:creator>Bricey</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79634.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=40&amp;PostID=79634</wfw:commentRss><description>&lt;p&gt;Hi there - I really&amp;nbsp;hope someone can help me out&amp;nbsp;here!&lt;br /&gt;&lt;br /&gt;I have an infopath browser based form that has a secondary SQL datasource connection. I have a field in my form that will match the data in SQL. I checked out Hilarys post from way back (&lt;a href="http://www.infopathdev.com/forums/p/8940/31780.aspx#31780"&gt;http://www.infopathdev.com/forums/p/8940/31780.aspx#31780&lt;/a&gt;) which is what I want to do, basically compare a value in the form, query the secondary source and then populate a list to a drop down.&lt;/p&gt;The code I am using is below but I get an saying it cant connect to the datasource. Also, Im unsure what drop down im supposed to be populating?! Hope someone can shed some light on this! &lt;font size="2"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; InternalStartup()&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;((&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;ButtonEvent&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)EventManager.ControlEvents[&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;CTRL324_6&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;]).Clicked += &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;ClickedEventHandler&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(CTRL324_6_Clicked);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;}&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; CTRL324_6_Clicked(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; sender, &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;ClickedEventArgs&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; e)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//get the value of the query field we want to use with a wild card&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; queryField = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:SelectDisplay/my:SalesPersonLkup&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; querySeed = queryField.Value;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//clear the query field so that it is ignored in the query&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;queryField.SetValue(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//create our custom where clause -- you have some choices here. I&amp;#39;ve added in the wildcard. You could choose not to, if your users are savvy and can fill it in themselves when searching, all up to you.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; customQuery = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; where ([SalesPersonLkup] like &amp;#39;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; + querySeed + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%&amp;#39;)&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//get the original command (we&amp;#39;ll need to set it back)&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; newQuery = (&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.DataSources[&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;FullInfo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;].QueryConnection;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; origCommand = newQuery.Command.ToString();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//set the query to use the custom command&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;newQuery.Command = origCommand + customQuery;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//annnnnnddddd, now we run the query using our shiny new command &lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;newQuery.Execute();&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//put everything back the way it was.... you&amp;#39;re going to need it!&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;newQuery.Command = origCommand;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//set the query field back for the user, so they know what they typed in!&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;queryField.SetValue(querySeed);&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Prodcues the errors:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The query cannot be run for the following DataObject: FullInfo&lt;br /&gt;InfoPath cannot run the specified query.&lt;br /&gt;[0x80040E14][Microsoft OLE DB Provider for SQL Server] Invalid column name &amp;#39;SalesPersonLkup&amp;#39;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;and &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;System.Net.WebException&lt;br /&gt;InfoPath has encountered an error. The operation failed.&lt;/p&gt;
&lt;p&gt;The form&amp;#39;s code contains an error. &lt;/p&gt;
&lt;p&gt;The following call in the form&amp;#39;s code failed: ADOAdapter.Query&lt;br /&gt;Operation aborted&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction(OMCall d)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.InfoPath.Internal.AdoQueryConnectionHost.Execute()&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Sales_Visit_Request_SQL_Connection.FormCode.CTRL324_6_Clicked(Object sender, ClickedEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)&lt;br /&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;</description></item></channel></rss>