Forum Moderators: open

Message Too Old, No Replies

parameter not being evaluated

sqlserver, parameter

         

belfasttim

7:55 pm on Nov 6, 2009 (gmt 0)

10+ Year Member



Hi --

I'm still plugging away on my asp.net app-- and I am trying to build a simple query that will grab some data based on the input from a drop down.

However, the parameter never gets set-- and I get SQL Server errors, since the query is invalid without the parameters being set.

Error:


Each GROUP BY expression must contain at least one column that is not an outer reference.

Here's my query and the param that never gets set-- I figured that if I set a default value it ought to work whether or not the dropdown control is working, right?


<asp:SqlDataSource ID="root" runat="server"
ConnectionString="<%$ ConnectionStrings:Stats_DevConnectionString %>"
SelectCommand="SELECT @view_type,COUNT([UniqueVisitors]) as u_visitors,
COUNT([Visits]) as visits,
COUNT([PageViews]) as pageviews
FROM [Report_WebPagesByProperty]
GROUP BY @view_type">
<SelectParameters>
<asp:ControlParameter Name="view_type" ControlID="DropDownList1" Type="String" PropertyName="SelectedValue" DefaultValue="Root" />
</SelectParameters>
</asp:SqlDataSource>

Thanks for any clues.

whoisgregg

2:47 pm on Nov 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd recommend running the query without using parameters to see if it's the parameter setting that's truly at fault.