0

我正在将下面的存储过程用于 SqlDataSource 的选择命令,并且我正在尝试传递查询字符串参数,但出现此错误:

过程或函数“ActivationCampaignGetById”需要参数“@campaignId”,但未提供该参数。

该参数存在于查询字符串中:

http://localhost:62681/Activations/ActivationCampaignDetails.aspx?id=98

这是我的数据源代码:

<asp:SqlDataSource ID="campaignDataSource" runat="server" ConflictDetection="CompareAllValues"
    ConnectionString="<%$ ConnectionStrings:ProVantageMediaManagement %>" 
    SelectCommand="ActivationCampaignGetById" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:QueryStringParameter DefaultValue="98" Name="campaignId" 
            QueryStringField="id" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

还有我的存储过程声明:

ALTER procedure [dbo].[ActivationCampaignGetById]
    @campaignId int
as
select
4

1 回答 1

4

不确定这会有所帮助,但您需要将参数方向设置为输入:

<asp:QueryStringParameter DefaultValue="98" Name="campaignId" 
       Direction="Input" QueryStringField="id" Type="Int32" />
于 2010-04-18T15:21:56.597 回答