我有这个 sqlDataSource
@userId 是系统中当前用户的参数。
<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>
在后面的代码中,我在 Page_Load 中有这个:
dsProfit.SelectParameters.Add("@userId", cui.getCurrentId());
public Guid getCurrentId()
{
MembershipUser currentUser = Membership.GetUser();
Guid currentUserId = (Guid)currentUser.ProviderUserKey;
return currentUserId;
}
启动页面时出现错误:必须声明标量变量“@userId”。