locked
Error Message Implementing AdminCategories.aspx - book Beginning ASP.NET E-Commerce in C # RRS feed

  • Question

  • User-576609655 posted

    Hello,

    I'm following the book "Beginning ASP.NET E-Commerce in C #, and I can not move because I get an error.

    I'm trying to work some days and I can not solve.

    I'm on page 325, "Implementing AdminCategories.aspx" in GridView.

    When I debug,
    appears a error message.

    Procedure or function 'CatalogGetCategoriesInDepartment' expects parameter '@ DepartmentID' Which was not supplied.

    Detalhes da Exceção: System.Data.SqlClient.SqlException: Procedure or function 'CatalogGetCategoriesInDepartment' expects parameter '@DepartmentID', which was not supplied.

    I've already made that part several times, I always get the same error.


    I have this.

        //retrieve the list of categories in a department
        public static DataTable GetCategoriesInDepartment(string departmentId)
        {
            //Get a configured DbCommand object
            DbCommand comm = GenericDataAccess.CreateCommand();
            //Set the stored procedure name
            comm.CommandText = "CatalogGetCategoriesInDepartment";
            //Create a new parameter
            DbParameter param = comm.CreateParameter();
            param.ParameterName = "@DepartmentID";
            param.Value = departmentId;
            param.DbType = DbType.Int32;
            comm.Parameters.Add(param);
    
            //Execute the stored procedure
            return GenericDataAccess.ExecuteSelectCommand(comm);
        }

    Does anyone know how I can fix this problem?

    I have no knowledge in asp.net I am learning.



    Saturday, September 25, 2010 4:41 PM

Answers

  • User1716267170 posted

    Did you check the passed string value and ensure it can be converted to a valid INT value? I think the code for adding a parameter is fine. Thanks. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 29, 2010 4:04 AM