|
Home > Archive > MS SQL Server > November 2006 > blank textbox is NOT null ..
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
blank textbox is NOT null ..
|
|
|
| This must be a common asp.net / sql server problem.
I only want to filter on the date when the filterdate textbox has a
value. Not sure if this is the best approach, but it does not appear to
be working.. I was hoping blank mean no filtering and all qualifying
rows returning
<asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
SelectCommand="SELECT * FROM & #91;GEN_RouteInfo_vw
] WHERE plancode =
@plancode and RouteCode=@RouteCode
and CountryId=@CountryId
and
startdate <= IsNull(cast(@DateFil
ter as datetime),cast('1/1/2999' as
datetime))and enddate >= IsNull(cast(@DateFil
ter as
datetime),cast('1/1/1999' as datetime)) order by StartDate" >
< asp:ControlParameter
ControlID="DateFilter" Name="DateFilter"
PropertyName="Text" Type="Datetime" />
| |
| John Bell 2006-11-16, 5:20 am |
| Hi
If you are going to dynamically create the SQL statement in you ASP then you
can omit the clause completely if no value is entered. If you are going to
use a stored procedure then check out
http://www.sommarskog.se/dyn-search.html and
http://www.sommarskog.se/dynamic_sql.html
John
"jobs" wrote:
> This must be a common asp.net / sql server problem.
>
> I only want to filter on the date when the filterdate textbox has a
> value. Not sure if this is the best approach, but it does not appear to
> be working.. I was hoping blank mean no filtering and all qualifying
> rows returning
>
> <asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
>
> SelectCommand="SELECT * FROM & #91;GEN_RouteInfo_vw
] WHERE plancode =
> @plancode and RouteCode=@RouteCode
and CountryId=@CountryId
and
> startdate <= IsNull(cast(@DateFil
ter as datetime),cast('1/1/2999' as
> datetime))and enddate >= IsNull(cast(@DateFil
ter as
> datetime),cast('1/1/1999' as datetime)) order by StartDate" >
>
> < asp:ControlParameter
ControlID="DateFilter" Name="DateFilter"
> PropertyName="Text" Type="Datetime" />
>
>
|
|
|
|
|