<?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>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42709.aspx</link><pubDate>Wed, 10 Jun 2009 16:51:41 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42709</guid><dc:creator>BuildPro Guru</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42709.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42709</wfw:commentRss><description>&lt;p&gt;Well, you got me on the right track and in the process i realized a few mistakes that I had made.&amp;nbsp; Here is my final code and it works like a charm:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; wwAlphMatch1 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;.IsNullOrEmpty(querySeed) ? &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; : &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;([WWALPH] like &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeed + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%&amp;#39; )and &amp;quot;&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="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; wwAlphMatch2 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;.IsNullOrEmpty(querySeedAddy) ? &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; : &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;([szLotAddress_201] like &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeedAddy + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%&amp;#39; )and &amp;quot;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; customQuery = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; where &amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + wwAlphMatch1 + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; (BuyerNumber in (Select BuyerNumber from Lots where &amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + wwAlphMatch2 + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; [Div_Desc] = &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeedDiv + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;#39;))&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Thanks so much for pointing me in the right direction!&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42594.aspx</link><pubDate>Mon, 08 Jun 2009 09:35:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42594</guid><dc:creator>BuildPro Guru</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42594.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42594</wfw:commentRss><description>&lt;p&gt;Hello Jimmy.&lt;/p&gt;
&lt;p&gt;Actually,&amp;nbsp;this is deployed&amp;nbsp;for 9 different divisions that are in the same DB&amp;nbsp;and I am using the div_desc to filter the results.&amp;nbsp; I think you are right about where the problem exists.&amp;nbsp; I will give your bit a whirl and let you know how it works out.&lt;/p&gt;</description></item><item><title>Re: Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42583.aspx</link><pubDate>Mon, 08 Jun 2009 04:50:24 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42583</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42583.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42583</wfw:commentRss><description>&lt;p&gt;Are you sure it&amp;#39;s returning &lt;em&gt;all&lt;/em&gt; the rows, and not just all the ones that match the Div_Desc value?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;It looks like the problem is this part:&lt;/p&gt;
&lt;p&gt;&lt;font color="#800000"&gt;([WWALPH] like &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeed + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%&amp;#39;)&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When querySeed is blank, this will evaluate to:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;font color="#800000"&gt;([WWALPH] like &amp;#39;&lt;/font&gt;&lt;font color="#800000" size="2"&gt;%&amp;#39;)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;which will match every row in the table.&amp;nbsp; You might want to try something like this:&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;&lt;font color="#000000"&gt;wwAlphMatch = string.IsNullOrEmpty(querySeed) ?&amp;nbsp;&amp;quot; = &amp;#39;&amp;#39;&amp;quot; :&amp;nbsp;&amp;quot;like &amp;#39;&amp;quot; + querySeed + &amp;quot;%&amp;#39;&amp;quot;;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt; customQuery = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; where ([WWALPH]&amp;nbsp;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + wwAlphMatch + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;) and (BuyerNumber in (Select BuyerNumber from Lots where [Div_Desc] = &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeedDiv + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;#39;))&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42580.aspx</link><pubDate>Mon, 08 Jun 2009 00:27:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42580</guid><dc:creator>BuildPro Guru</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42580.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42580</wfw:commentRss><description>&lt;p&gt;Hello Hilary.&amp;nbsp; Yep.&amp;nbsp; It works teriffic as long as I dont leave the WWALPH field blank.&amp;nbsp; &lt;/p&gt;</description></item><item><title>Re: Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42560.aspx</link><pubDate>Sat, 06 Jun 2009 06:33:51 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42560</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42560.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42560</wfw:commentRss><description>&lt;p&gt;Have you run your code in debug to verify that newQuery.Command is exactly what you&amp;#39;d expect it to be?&lt;/p&gt;</description></item><item><title>Ignore Blanks in Query</title><link>https://www.infopathdev.com:443/forums/thread/42447.aspx</link><pubDate>Wed, 03 Jun 2009 18:27:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42447</guid><dc:creator>BuildPro Guru</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42447.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42447</wfw:commentRss><description>&lt;p&gt;Hello Everyone.&lt;/p&gt;
&lt;p&gt;IP 2007 + C#.&amp;nbsp; I have a form based on a SQL DB and I am using query fields from two tables - the parent table and one other table.&amp;nbsp; If any of the query fields from the&amp;nbsp;parent table are blank, the query will return ALL of the data in that table.&amp;nbsp; So I will have 20k+ records returned, but only one of them will have the rest of the&amp;nbsp;information.&amp;nbsp; How do&amp;nbsp;I get it to ignore the blank fields in the parent table?&amp;nbsp; Here is the bit of code that&amp;nbsp;executes the query:&lt;/p&gt;&amp;nbsp;&amp;nbsp;&lt;font color="#008000" size="2"&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt; 
&lt;p&gt;//get the value of the buyer and division fields&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;XPathNavigator&lt;/font&gt;&lt;font size="2"&gt; queryField = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:queryFields/q:Buyers/@WWALPH&amp;quot;&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;string&lt;/font&gt;&lt;font size="2"&gt; querySeed = queryField.Value;&lt;/p&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;XPathNavigator&lt;/font&gt;&lt;font size="2"&gt; queryFieldDiv = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:queryFields/q:Lots/@div_desc&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; querySeedDiv = queryFieldDiv.Value;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//clear the query fields so they are ignored in the query&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;queryField.SetValue(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;queryFieldDiv.SetValue(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//create&amp;nbsp;custom where clauses (one for buyer and one for divsion)&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; customQuery = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot; where ([WWALPH] like &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeed + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%&amp;#39;) and (BuyerNumber in (Select BuyerNumber from Lots where [Div_Desc] = &amp;#39;&amp;quot;&lt;/font&gt;&lt;font size="2"&gt; + querySeedDiv + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;#39;))&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//get the original command&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;font size="2"&gt; newQuery = (&lt;/font&gt;&lt;font color="#008080" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;font size="2"&gt;)MainDataSource.QueryConnection;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; origCommand = newQuery.Command.ToString();&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//Locate the end of the buyers shape in the command&amp;nbsp;and add the buyers where clause&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;font size="2"&gt; firstBrace = origCommand.IndexOf(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;}&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//Insert the where clause at the end of the buyers shape&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; origCommandFirstHalf = origCommand.Substring(0, firstBrace);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; origCommandSecondHalf = origCommand.Substring(firstBrace, origCommand.Length - origCommandFirstHalf.Length);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;newQuery.Command = origCommandFirstHalf + customQuery + origCommandSecondHalf;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//run the query using new command &lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;newQuery.Execute();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//put everything back&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;newQuery.Command = origCommand;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;//set the query field back&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;queryField.SetValue(querySeed);&lt;/p&gt;
&lt;p&gt;queryFieldDiv.SetValue(querySeedDiv);&lt;/p&gt;&lt;/font&gt;</description></item></channel></rss>