locked
SqlCeParameter Error! RRS feed

  • Question

  • User-76754549 posted

    Whenever i try to post values , i get this error!

    An SqlCeParameter with ParameterName '25' is not contained by this SqlCeParameterCollection.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.IndexOutOfRangeException: An SqlCeParameter with ParameterName '25' is not contained by this SqlCeParameterCollection.

    Source Error: 

    Line 87: 
    Line 88:     var db = Database.Open("Documents");
    Line 89: db.Execute(@"INSERT INTO Diploma_Leaving (UserId, LC_no, Book_no, Register_no, Religion, Caste, Sub_caste, Nationality, Birth_place,District, Birth_date, Prev_school_college, Admission_date, Conduct, Progress, Leaving_date, Studying_class, Studying_month, Studying_year, Reason,Remark, Division, Exam, Exam_year, Seat_no, Enrollment) Line 90:          VALUES (@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,@17,@18,@19,@20,@21,@22,@23,@24,@25)",UserId, LC_no, Book_no, Register_no, Caste,Sub_caste, Nationality, Birth_place, District,DOB,Prev_school_college,Admission_date,Conduct,Progress,Leaving_date, Studying_class, Studying_month, Studying_year,Reason,Remark,Division,Exam,Exam_year,Seat_no,Enrollment);
    Line 91: }

    Stack Trace: 

    [IndexOutOfRangeException: An SqlCeParameter with ParameterName '25' is not contained by this SqlCeParameterCollection.]
       System.Data.SqlServerCe.SqlCeParameterCollection.ThrowParamterNotFoundException(String parameterName) +188
       System.Data.SqlServerCe.SqlCeParameterCollection.RangeCheck(String parameterName, SqlCeParameter& param) +122
       System.Data.SqlServerCe.SqlCeParameterCollection.get_Item(String parameterName) +19
       System.Data.SqlServerCe.SqlCeCommand.CreateParameterAccessor(MetaData[] metadata) +149
       System.Data.SqlServerCe.SqlCeCommand.CreateDataBindings() +103
       System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() +700
       System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) +542
       System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() +21
       WebMatrix.Data.Database.Execute(String commandText, Object[] args) +116
       ASP.<>c__DisplayClass28.<Insert_Diploma_Leaving>b__27(TextWriter __razor_helper_writer) in c:\Users\XBlaZE\Documents\My Web Sites\HomeManagementSystem\App_Code\Helper.cshtml:89
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
       System.Web.WebPages.WebPageBase.Write(HelperResult result) +71
       ASP._Page_Testing_Page2_cshtml.Execute() in c:\Users\XBlaZE\Documents\My Web Sites\HomeManagementSystem\Testing\Page2.cshtml:40
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
       System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +151
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
       System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +114
    Friday, August 9, 2013 4:00 PM

Answers

  • User281315223 posted

    It's likely that you could be missing a parameter (which could result in your query being off).

    @0 - UserId
    @1 - LC_no
    @2 - Book_no
    @3 - Register_no
    @4 - Caste
    @5 - Sub_caste
    @6 - Nationality
    @7 - Birth_place
    @8 - District
    @9 - DOB
    @10 - Prev_school_college
    @11 - Admission_date
    @12 - Conduct
    @13 - Progress
    @14 - Leaving_date
    @15 - Studying_class
    @16 - Studying_month
    @17 - Studying_year
    @18 - Reason
    @19 - Remark
    @20 - Division
    @21 - Exam
    @22 - Exam_year
    @23 - Seat_no
    @24 - Enrollment
    @25 - ?

    After looking at it a bit more, it appears that you forgot to include the 'Religion' parameter : 

    db.Execute(@"INSERT INTO Diploma_Leaving (UserId, LC_no, Book_no, Register_no, Religion, Caste, Sub_caste, Nationality, Birth_place,District, Birth_date, Prev_school_college, Admission_date, Conduct, Progress, Leaving_date, Studying_class, Studying_month, Studying_year, Reason,Remark, Division, Exam, Exam_year, Seat_no, Enrollment) VALUES (@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,@17,@18,@19,@20,@21,@22,@23,@24,@25)",UserId, LC_no, Book_no, Register_no,Religion, Caste,Sub_caste, Nationality, Birth_place, District,DOB,Prev_school_college,Admission_date,Conduct,Progress,Leaving_date, Studying_class, Studying_month, Studying_year,Reason,Remark,Division,Exam,Exam_year,Seat_no,Enrollment);



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 9, 2013 4:10 PM

All replies

  • User281315223 posted

    It's likely that you could be missing a parameter (which could result in your query being off).

    @0 - UserId
    @1 - LC_no
    @2 - Book_no
    @3 - Register_no
    @4 - Caste
    @5 - Sub_caste
    @6 - Nationality
    @7 - Birth_place
    @8 - District
    @9 - DOB
    @10 - Prev_school_college
    @11 - Admission_date
    @12 - Conduct
    @13 - Progress
    @14 - Leaving_date
    @15 - Studying_class
    @16 - Studying_month
    @17 - Studying_year
    @18 - Reason
    @19 - Remark
    @20 - Division
    @21 - Exam
    @22 - Exam_year
    @23 - Seat_no
    @24 - Enrollment
    @25 - ?

    After looking at it a bit more, it appears that you forgot to include the 'Religion' parameter : 

    db.Execute(@"INSERT INTO Diploma_Leaving (UserId, LC_no, Book_no, Register_no, Religion, Caste, Sub_caste, Nationality, Birth_place,District, Birth_date, Prev_school_college, Admission_date, Conduct, Progress, Leaving_date, Studying_class, Studying_month, Studying_year, Reason,Remark, Division, Exam, Exam_year, Seat_no, Enrollment) VALUES (@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,@17,@18,@19,@20,@21,@22,@23,@24,@25)",UserId, LC_no, Book_no, Register_no,Religion, Caste,Sub_caste, Nationality, Birth_place, District,DOB,Prev_school_college,Admission_date,Conduct,Progress,Leaving_date, Studying_class, Studying_month, Studying_year,Reason,Remark,Division,Exam,Exam_year,Seat_no,Enrollment);



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 9, 2013 4:10 PM
  • User-76754549 posted

    Dam............ it was so easy one! thanx for the answer! Embarassed

    Friday, August 9, 2013 4:20 PM