Difficulties with Selectparameters

Joined
Sep 6, 2007
Messages
2
Reaction score
0
Forum,

I have a query with a Selectparameter, however my Selectparameter is not always present, and in that case, I would like the query to return all records.

I'm using a column called status for the parameter. Status is an tinyint that IS NOT NULL.

Psuedo code:

<asp:SqlDataSource ID="sqlMy" runat="server" ConnectionString="<%$ ConnectionStrings:myConnStr%>"
SelectCommand="SELECT *, FROM [myTbl] WHERE status = @status">
<SelectParameters>
<asp:QueryStringParameter Name="status" QueryStringField="status" DefaultValue="" />
</SelectParameters>
</asp:SqlDataSource>

Suggestions?

Thank you,

Ray K. Ragan
 
Joined
Sep 6, 2007
Messages
2
Reaction score
0
Forum,

I got it:

<asp:SqlDataSource ID="sqlMy" runat="server" ConnectionString="<%$ ConnectionStrings:MyConStr%>"
SelectCommand="SELECT *, FROM [myTbl] WHERE (@status = '' OR status = @status)">
<SelectParameters>
<asp:QueryStringParameter Name="status" QueryStringField="status" DefaultValue="" ConvertEmptyStringToNull="false" />
</SelectParameters>
</asp:SqlDataSource>

Thank you,

Ray K. Ragan
 
Last edited:

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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top