ProfK
ProfK

Reputation: 51114

Select parameter not working on SqlDataSource

I am using the stored procedure below for the select command of a SqlDataSource, and I'm trying to pass a query string parameter, but I get this error:

Procedure or function 'ActivationCampaignGetById' expects parameter '@campaignId', which was not supplied.

The parameter is present in the query string:

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

Here is my DataSource code:

<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>

And my stored procedure declaration:

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

Upvotes: 0

Views: 3069

Answers (1)

Oded
Oded

Reputation: 499382

Not sure this will helps, but you need to set the parameter direction to Input:

<asp:QueryStringParameter DefaultValue="98" Name="campaignId" 
       Direction="Input" QueryStringField="id" Type="Int32" />

Upvotes: 4

Related Questions