I have this sqlDataSource
@userId is my parameter for Current user in a system .
<asp:SqlDataSource ID="dsProfit" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="select name, sum(value) as suma from AllProfitView where IdUser=@userId group by name order by sum(value) desc">
</asp:SqlDataSource>
In code Behind I have this in Page_Load :
dsProfit.SelectParameters.Add("@userId", cui.getCurrentId());
public Guid getCurrentId()
{
MembershipUser currentUser = Membership.GetUser();
Guid currentUserId = (Guid)currentUser.ProviderUserKey;
return currentUserId;
}
when start the page it's blows with ERROR :Must declare the scalar variable "@userId".