Barguast
Barguast

Reputation: 6196

SqlDataSource strange behaviour

For the life of me, I can't understand this problem. Basically, I have a SqlDataSource which is refusing to return data if there are ANY select parameters. For instance;

<asp:SqlDataSource ID="sdsSubscriptions" runat="server"
    ConnectionString='<%$ ConnectionStrings:DBConnectionString %>'
    SelectCommand="SELECT ID, Description FROM Subscription.[Subscriptions">
    <SelectParameters>
        <asp:Parameter Name="UserID" Type="Int32" Direction="Input" />
    </SelectParameters>
</asp:SqlDataSource>

The above does not work. If I remove the SelectParameters, it does work.

In my actual web site, the UserID parameter is used. I arrived at the above code after reducing it to find the problem.

Does anyone know why this might be happening? Thanks

Upvotes: 1

Views: 57

Answers (1)

abatishchev
abatishchev

Reputation: 100366

If SelectCommand contains no parameters, you should not specify any SelectParameters.

Upvotes: 1

Related Questions