Must declare the scalar variable "@PaperID"

0
 <asp:SqlDataSource runat="server" ID="sdsFormViewPaper"
        ConnectionString="<%$ConnectionStrings:CPMS%>"
        OldValuesParameterFormatString="original_{0}" 
        OnInserted="sdsFormViewPaper_Inserted"
        SelectCommand="SELECT *
                         FROM Paper, Author
                        WHERE Paper.AuthorID = Author.AuthorID
                        ORDER BY PaperID;"
        InsertCommand="INSERT
                         INTO Paper
                            (
                              Active,
                              FilenameOriginal,
                              Filename,
                              Title,
                              Certification,
                              NotesToReviewers,
                              AnalysisOfAlgorithms,
                              Applications,
                              Architecture,
                              ArtificialIntelligence,
                              ComputerEngineering,
                              Curriculum,
                              DataStructures,
                              Databases,
                              DistanceLearning,
                              DistributedSystems,
                              EthicalSocietalIssues,
                              FirstYearComputing,
                              GenderIssues,
                              GrantWriting,
                              GraphicsImageProcessing,
                              HumanComputerInteraction,
                              LaboratoryEnvironments,
                              Literacy,
                              MathematicsInComputing,
                              Multimedia,
                              NetworkingDataCommunications,
                              NonMajorCourses,
                              ObjectOrientedIssues,
                              OperatingSystems,
                              ParallelProcessing,
                              Pedagogy,
                              ProgrammingLanguages,
                              Research,
                              Security,
                              SoftwareEngineering,
                              SystemsAnalysisAndDesign,
                              UsingTechnologyInTheClassroom,
                              WebAndInternetProgramming,
                              Other,
                              OtherDescription
                            )
                       VALUES
                            (
                              @Active,
                              @FilenameOriginal,
                              @Filename,
                              @Title,
                              @Certification,
                              @NotesToReviewers,
                              @AnalysisOfAlgorithms,
                              @Applications,
                              @Architecture,
                              @ArtificialIntelligence,
                              @ComputerEngineering,
                              @Curriculum,
                              @DataStructures,
                              @Databases,
                              @DistanceLearning,
                              @DistributedSystems,
                              @EthicalSocietalIssues,
                              @FirstYearComputing,
                              @GenderIssues,
                              @GrantWriting,
                              @GraphicsImageProcessing,
                              @HumanComputerInteraction,
                              @LaboratoryEnvironments,
                              @Literacy,
                              @MathematicsInComputing,
                              @Multimedia,
                              @NetworkingDataCommunications,
                              @NonMajorCourses,
                              @ObjectOrientedIssues,
                              @OperatingSystems,
                              @ParallelProcessing,
                              @Pedagogy,
                              @ProgrammingLanguages,
                              @Research,
                              @Security,
                              @SoftwareEngineering,
                              @SystemsAnalysisAndDesign,
                              @UsingTechnologyInTheClassroom,
                              @WebAndInternetProgramming,
                              @Other,
                              @OtherDescription
                            );
                       SELECT @PaperID = SCOPE_IDENTITY();"
        UpdateCommand="UPDATE Paper
                          SET Active = @Active,
                              FilenameOriginal = @FilenameOriginal,
                              Filename = @Filename,
                              Title = @Title,
                              Certification = @Certification,
                              NotesToReviewers = @NotesToReviewers,
                              AnalysisOfAlgorithms = @AnalysisOfAlgorithms,
                              Applications = @Applications,
                              Architecture = @Architecture,
                              ArtificialIntelligence = @ArtificialIntelligence,
                              ComputerEngineering = @ComputerEngineering,
                              Curriculum = @Curriculum,
                              DataStructures = @DataStructures,
                              Databases = @Databases,
                              DistanceLearning = @DistanceLearning,
                              DistributedSystems = @DistributedSystems,
                              EthicalSocietalIssues = @EthicalSocietalIssues,
                              FirstYearComputing = @FirstYearComputing,
                              GenderIssues = @GenderIssues,
                              GrantWriting = @GrantWriting,
                              GraphicsImageProcessing = @GraphicsImageProcessing,
                              HumanComputerInteraction = @HumanComputerInteraction,
                              LaboratoryEnvironments = @LaboratoryEnvironments,
                              Literacy = @Literacy,
                              MathematicsInComputing = @MathematicsInComputing,
                              Multimedia = @Multimedia,
                              NetworkingDataCommunications = @NetworkingDataCommunications,
                              NonMajorCourses = @NonMajorCourses,
                              ObjectOrientedIssues = @ObjectOrientedIssues,
                              OperatingSystems = @OperatingSystems,
                              ParallelProcessing = @ParallelProcessing,
                              Pedagogy  = @Pedagogy,
                              ProgrammingLanguages = @ProgrammingLanguages,
                              Research = @Research,
                              Security = @Security,
                              SoftwareEngineering = @SoftwareEngineering,
                              SystemsAnalysisAndDesign  = @SystemsAnalysisAndDesign,
                              UsingTechnologyInTheClassroom = @UsingTechnologyInTheClassroom,
                              WebAndInternetProgramming = @WebAndInternetProgramming,
                              OtherDescription = @OtherDescription,
                              Other = @Other
                        WHERE PaperID = @original_PaperID;"
        DeleteCommand="DELETE
                         FROM Paper
                        WHERE PaperID = @original_PaperID;">

Must declare the scalar variable "@PaperID". 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.Data.SqlClient.SqlException: Must declare the scalar variable "@PaperID".

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Must declare the scalar variable "@PaperID".]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,

sql
asp.net
sql-server
asked on Stack Overflow Apr 5, 2019 by Isiah Jones • edited Apr 5, 2019 by Dale K

1 Answer

0

Add below line in the InsertCommand:

Declare @PaperID INT -- adding this would resolve your exception

SELECT @PaperID = SCOPE_IDENTITY();
answered on Stack Overflow Apr 5, 2019 by Ashok • edited Apr 5, 2019 by Dale K

User contributions licensed under CC BY-SA 3.0