vs2010 asp.net : Procedure or function expects parameter which was not supplied.

Posted by dotnet-practitioner on Stack Overflow See other posts from Stack Overflow or by dotnet-practitioner
Published on 2010-04-29T02:02:22Z Indexed on 2010/04/29 2:07 UTC
Read the original article Hit count: 662

Filed under:
|

I have googled for this issue but listed solutions are not working for me...

I get the following error message:

Procedure or function 'ContactHide' expects parameter '@ContactID', which was not supplied.

Here is my setup..What am I missing? Please help? Debugger shows that I am supplying ContactID correctly in my C# code behind code.

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:MYDBConnectionString1 %>" 
    UpdateCommand="ContactHide" UpdateCommandType="StoredProcedure"
    >

        int contactid= Convert.ToInt32(e.CommandArgument);
        SqlDataSource2.UpdateParameters.Add("@ContactID", System.Data.DbType.Int32, "1");
        SqlDataSource2.UpdateParameters["@ContactID"].DefaultValue = contactid.ToString();
        SqlDataSource2.Update();


ALTER PROCEDURE dbo.ContactHide
    @ContactID int
    /*
    (
    @parameter1 int = 5,
    @parameter2 datatype OUTPUT
    )
    */
AS
    Update Contacts set Visible = 0 where ContactID = isnull(@ContactID,-1)

    /* SET NOCOUNT ON */
    RETURN

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about sqldatasource