Sqldatasource parameter date

S

SMXBob

I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record comes
back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.

Thanks for any suggestionsk
 
G

Guest

I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record comes
back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.

Thanks for any suggestionsk

I think you can set the date of tomorrow to show all records.
 
A

Andrew Morton

SMXBob said:
I have a slight problem resetting a date select parameter in that I
can't get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

If you want to include the null ones, then surely you'd want to include them
in the predicate:

SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm OR [DueDate] IS
NULL)
 
S

SMXBob

Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that date
(see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I remove
it when I want just my date selection.
 
P

Paul Shapiro

SELECT * FROM [MyTable]
WHERE ([DueDate] < @DueDateParm) Or (@DueDateParm Is Null)

SMXBob said:
Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that
date (see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I
remove it when I want just my date selection.



SMXBob said:
I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors less
than that date. But I can't figure out how to reset it so every record
comes back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.
 
S

SMXBob

Thanks Paul

I don't think I would have ever thought of that one.

Good job!


Paul Shapiro said:
SELECT * FROM [MyTable]
WHERE ([DueDate] < @DueDateParm) Or (@DueDateParm Is Null)

SMXBob said:
Please notice what I am trying to do here.

If I set the DueDateParm to a date I get all the records less then that
date (see my query).
The result set does NOT include nulls which is how it is suppose to work.

What I then want is the option to return all rows including nulls.
The OR option would work but I am back to my initial problem how do I
remove it when I want just my date selection.



SMXBob said:
I have a slight problem resetting a date select parameter in that I can't
get the records with null dates.
For instance this select statement

SelectCommand="SELECT * FROM [MyTable] WHERE ([DueDate] < @DueDateParm)"

<asp:SessionParameter
Name="DueDateParm"
SessionField="DueDateParm"
DefaultValue=""
ConvertEmptyStringToNull="true"
DbType="DateTime" />

If I set DueDateParm to a date it works fine I get all of the recors
less than that date. But I can't figure out how to reset it so every
record comes back.Records with Null dates are not selected.
The only method I can find is Clear but it clears ALL parameters. I just
want to reset this one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top