<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/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 Server, SQL Server Express, and SqlDataSource Control</title><link>http://forums.asp.net/54.aspx</link><description>All about SQL Server, SQL Server Express, MSDE, and the SqlDataSource control.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3274659.aspx</link><pubDate>Sat, 04 Jul 2009 12:52:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274659</guid><dc:creator>SpawnTheUndead</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274659.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3274659</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;OK, The next code&amp;nbsp;works fine.&lt;/p&gt;
&lt;p&gt;When you want to specify a value for parameter:&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;font size="2"&gt;
&lt;p&gt;dsSQL.SelectParameters.Add(&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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Parametro&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.Boolean, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;True&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;))&lt;/font&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;
&lt;p&gt;And.... when you want to specify the null value... guess what... just remove parameter:&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;
&lt;p&gt;dsSQL.SelectParameters.Remove(dsSQL.SelectParameters.Item(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Parametro&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;))&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3042886.aspx</link><pubDate>Fri, 27 Mar 2009 13:25:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3042886</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3042886.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3042886</wfw:commentRss><description>&lt;p&gt;Well I have played and played with this and I cannot get a null value check to work in the query using the value from the parameter.&amp;nbsp; I don&amp;#39;t really think this is &amp;quot;Resolved&amp;quot; but I&amp;#39;m going to to mark it as such since I have&amp;nbsp;a functional work around, and I&amp;#39;m sure we would all like to move on.&amp;nbsp; Thank you both for your time and input I&amp;#39;ve given you both credit for helping with the solution.&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3040961.aspx</link><pubDate>Thu, 26 Mar 2009 19:23:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3040961</guid><dc:creator>Naom</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3040961.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3040961</wfw:commentRss><description>&lt;p&gt;Did you try to add parameter as text and only then set its value to DbNull.Value in the code from the second message?&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3040916.aspx</link><pubDate>Thu, 26 Mar 2009 19:02:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3040916</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3040916.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3040916</wfw:commentRss><description>&lt;p&gt;Yes it is passing an empty string.&amp;nbsp; I have already proven that.&amp;nbsp; What I was trying to figure out is why it would not pass a null value.&lt;/p&gt;
&lt;p&gt;According to what I was reading on MSDN the attribute &amp;quot;ConvertEmptyStringToNull&amp;quot; for the parameter should force it to push a Null value to the query, &amp;quot;how-some-ever-comma&amp;quot; it keeps pushing an empty string, which SQL does interpret the same way of course &amp;#39;empty string&amp;#39; &amp;lt;&amp;gt; Null = True&lt;/p&gt;
&lt;p&gt;This is why I can&amp;#39;t simply use the IsNull function in the query and have to work with strings.&amp;nbsp; As a test I made my routine convert &amp;#39;&amp;#39; to &amp;#39;NoValue&amp;#39; just to as a test, but in short yes it passes empty string, EmptyStringToNull&amp;nbsp;= Broken since I can&amp;#39;t seem to actually pass a Null Value to the query with the parameter.&amp;nbsp; Also DBNull.Value.Equals(ParamaterValue) does not pass the value as null.&amp;nbsp; It&amp;#39;s a minor inconvenience since programatically everything is working fine, I just don&amp;#39;t understand why the Null value is not being passed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!!!&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3040410.aspx</link><pubDate>Thu, 26 Mar 2009 15:52:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3040410</guid><dc:creator>Naom</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3040410.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3040410</wfw:commentRss><description>&lt;p&gt;What is the type of the parameter? May be you&amp;#39;re passing an empty string instead?&lt;/p&gt;
&lt;p&gt;E.g. test with &lt;/p&gt;
&lt;p&gt;@AcctNo IS NULL or LEN(LTRIM(@AcctNo)) = 0&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3040328.aspx</link><pubDate>Thu, 26 Mar 2009 14:47:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3040328</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3040328.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3040328</wfw:commentRss><description>&lt;p&gt;Still a no-go grr.&amp;nbsp; I can&amp;#39;t seem to get a null value to pass with the parameter the &amp;quot;IsNull&amp;quot; SQL function is checking as&amp;nbsp;FALSE on that parameter no matter what I try...DBNull.Value.Equals(Parameter) ..... Parameter.ConvertEmptyStringToNull = True .... Nothing seems to work.&amp;nbsp; If I convert the empty string into &amp;quot;NoValue&amp;quot; then it works but not if I try to pass a Null.&amp;nbsp; It&amp;#39;s working now so I&amp;#39;m just going to run with it like it is, it&amp;#39;s still cleaner then trying to build a my where clause on the fly ... it just aggrevates me to no end that I can&amp;#39;t seem to get a Null value to pass.&amp;nbsp; Everything I&amp;#39;m reading says this should work but I can&amp;#39;t figure it out.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s what I&amp;#39;m finally running with maybe someone can see what I&amp;#39;m over looking:&lt;/p&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;
&lt;p&gt;Where (AccNo = (Case When @AcctNo = &amp;#39;NoValue&amp;#39; Then AccNo Else @AcctNo End))&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; CustNo &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&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; = TBCustNo.Text&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;If&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; CustNo = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&amp;quot;&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;Then&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;CustNo = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;NoValue&amp;quot;&lt;/p&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;&lt;font color="#0000ff" size="2"&gt;End&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;If&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;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; PacctNo &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; Parameter = &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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AcctNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.String, CustNo)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;PacctNo.ConvertEmptyStringToNull = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;True&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;SQLARSummary.SelectParameters.Add(PacctNo)&lt;/p&gt;
&lt;p&gt;Thank you everyone for your time and input!&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3038629.aspx</link><pubDate>Thu, 26 Mar 2009 03:34:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3038629</guid><dc:creator>Naom</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3038629.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3038629</wfw:commentRss><description>&lt;p&gt;&lt;font color="#a31515"&gt;try&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Where (AccNo = (Case When ISNULL(@AcctNo,&amp;#39;NoValue&amp;#39;) = &amp;#39;NoValue&amp;#39; Then AccNo Else @AcctNo End)) &lt;font size="2"&gt;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3034664.aspx</link><pubDate>Tue, 24 Mar 2009 20:09:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3034664</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3034664.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3034664</wfw:commentRss><description>&lt;p&gt;Ok I got this to work, but I still can&amp;#39;t seem to get it to work when dealing with Null or empty values:&amp;nbsp;&lt;/p&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;
&lt;p&gt;Where (AccNo = (Case When @AcctNo = &amp;#39;NoValue&amp;#39; Then AccNo Else @AcctNo End)) &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;SQLARSummary.SelectParameters.Clear()&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; CustNo &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&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; = TBCustNo.Text&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;If&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; CustNo = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&amp;quot;&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;Then&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;CustNo = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;NoValue&amp;quot;&lt;/p&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;&lt;font color="#0000ff" size="2"&gt;End&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;If&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;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; PAcctNo &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; Parameter = &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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AcctNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.String, CustNo)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;SQLARSummary.SelectParameters.Add(PAcctNo)&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3034611.aspx</link><pubDate>Tue, 24 Mar 2009 19:46:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3034611</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3034611.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3034611</wfw:commentRss><description>&lt;p&gt;Sorry this is a &amp;quot;no-go&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;vemulapalli26:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;SQLARSummary.SelectParameters.Add(&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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.Decimal, DBNull.Value))&lt;/font&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;The DBNull.value throws an error that this number of arguments not excepted.&amp;nbsp; If I manually replace the @AccNo in the query with &amp;quot;Null&amp;quot; it works fine so in theory this would work, but the parameter does not seem to properly pass a NULL value.&amp;nbsp; I tried setting the ConvertEmptyStringToNull property equal to &amp;quot;True&amp;quot; this didn&amp;#39;t work either.&amp;nbsp; If I can just get the parameter to actually pass a &amp;quot;Null&amp;quot; into the SelectCommand that I think this would be the ticket and would be much easier and cleaner then trying to write on the fly Where statements.&amp;nbsp; I&amp;#39;ll continue to dig around and see if I can find the missing piece of the puzzle.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;</description></item><item><title>Re: Working With SelectParameters</title><link>http://forums.asp.net/thread/3034518.aspx</link><pubDate>Tue, 24 Mar 2009 19:05:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3034518</guid><dc:creator>vemulapalli26</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3034518.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3034518</wfw:commentRss><description>&lt;p&gt;try this &lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt;&lt;font size="2"&gt; strSQL &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&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; = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Select&amp;nbsp;* From ARAging Where AccNo = ISNULL(@AccNo,AccNo)&amp;nbsp;Order By AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;if(TBCustNo.Text&amp;nbsp;&amp;lt;&amp;gt; string.empty)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;SQLARSummary.SelectParameters.Add(&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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.Decimal, TBCustNo.Text)) &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;else&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;SQLARSummary.SelectParameters.Add(&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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.Decimal, DBNull.Value)) &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;</description></item><item><title>Working With SelectParameters</title><link>http://forums.asp.net/thread/3034468.aspx</link><pubDate>Tue, 24 Mar 2009 18:43:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3034468</guid><dc:creator>Loganix77</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3034468.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3034468</wfw:commentRss><description>&lt;p&gt;I hope there is a quick answer to this question :)&lt;/p&gt;
&lt;p&gt;I have a SQLDataSource I&amp;#39;m using to pull all of the information from a table housing our aging AR information.&amp;nbsp; I&amp;#39;m trying to build a search feature to narrow this information down since there are over 5000 accounts in aging AR.&amp;nbsp; The select statement works fine and the gridview looks great up until I try adding some some selectparameters (this is new to me, I normally just build a where clause dynamically and add it back to the select string, but parameters looks like it would be much cleaner if I can get it to work like the owners would like).&amp;nbsp; The problem I&amp;#39;m having is that if on the &amp;quot;Aging AR Report&amp;quot; you click generate without putting a value into the &amp;quot;CustNo&amp;quot; field I get back 0 rows of data.&amp;nbsp; I put AccNo &amp;quot;3&amp;quot; into the text box and click generate I get back 1 row for the CustNo requested.&amp;nbsp; What I would like to do is be able to leave all fields blank that reference a parameter and if the field is blank it is excluded.&amp;nbsp; So in short if all my textboxes that are associated with ControlParameters = Nothing Then I get back ~5000 rows, not 0, the AR Dept can then use the sort method of the gridview to put accounts with higher outstanding balances to the top of the list.&lt;/p&gt;
&lt;p&gt;Rough Code Example:&lt;/p&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;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; strSQL &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&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; = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Select&amp;nbsp;* From ARAging Where AccNo = @AccNo&amp;nbsp;Order By AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;
&lt;p&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;SQLARSummary.SelectParameters.Add(&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; Parameter(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;AccNo&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, Data.DbType.Decimal, TBCustNo.Text)) 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;SQLARSummary.ConnectionString = ConfigurationManager.ConnectionStrings(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;XXXXXXXXXXXXX&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).ConnectionString&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;SQLARSummary.SelectCommand = strSQL&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;GVARSummary.DataSourceID = SQLARSummary.ID.ToString&lt;/p&gt;
&lt;p&gt;GVARSummary.DataBind()&lt;/p&gt;
&lt;p&gt;&amp;nbsp;In the above example if I leave the texbox &amp;quot;TBCustNo&amp;quot; blank, I will retrieve 0 rows.&amp;nbsp; If I place a valid CustNo in this field I will retrieve 1 row.&amp;nbsp; How can I configure this parameter so if the textbox is left blank the report will retrieve all 5000+ records?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thanks a lot for any help!!&lt;/p&gt;&lt;/font&gt;</description></item></channel></rss>