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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top