'执行命令定义时发生错误。有关详细信息,请参见内部异常。

时间:2020-03-30 17:57:21

标签: c# sql-server entity-framework-6

我收到此错误:

执行命令定义时发生错误。有关详细信息,请参见内部异常

SqlException:过程或函数SP_WEB_MS3DailyReport_DailyEquipmentDeviation_SelectByDate指定了太多参数。

我的代码:

ALTER PROCEDURE [dbo].[SP_WEB_MS3DailyReport_NonBuilDeviation_SelectByDate]
    (@FromDate datetime,
     @EndDate datetime)
AS
BEGIN
    SELECT
        JobHead,
        ISNULL(MeasurementPlanned, 0) AS MeasurementPlanned,
        CASE
           WHEN Deviation IS NULL THEN CONVERT(Numeric(18, 2), 0)
           ELSE CONVERT(Numeric(18, 2), MeasurementReport)
        END AS MeasurementReport,
        CASE
           WHEN MeasurementReport IS NULL THEN -(MeasurementPlanned)
           ELSE Deviation
        END AS Deviation,
        CASE
           WHEN MeasurementPlanned IS NULL AND Deviation > 0 THEN 'btn-info'
           WHEN Deviation = 0 THEN 'btn-primary'
           WHEN Deviation > 0 THEN 'btn-success'
           WHEN Deviation < 0 THEN 'btn-danger' 
           WHEN Deviation IS NULL THEN 'btn-warning'
        END AS Indicater,
        ProjectSiteName, ProjectSiteID
    FROM
        (SELECT
             DailyNonBuildReviewDeviation.[JobHead],
             CONVERT(Numeric(18, 2), NextDayNonBuildPlan.Measurement) AS MeasurementPlanned,
             CONVERT(Numeric(18, 2), DailyNonBuildReport.Measurement) AS MeasurementReport,
             CONVERT(Numeric(18, 2), DailyNonBuildReviewDeviation.Measurement) AS Deviation,
             ProjectSiteName, DailyNonBuildReviewDeviation.ProjectSiteID
         FROM
             DailyNonBuildReviewDeviation
         LEFT JOIN
             NextDayNonBuildPlan ON DailyNonBuildReviewDeviation.NextDayNonBuildPlanID = NextDayNonBuildPlan.NextDayNonBuildPlanID
         LEFT JOIN 
             [DailyNonBuildReport] ON DailyNonBuildReviewDeviation.DailyNonBuildReportID = DailyNonBuildReport.DailyNonBuildReportID
         INNER JOIN 
             ProjectSites ON ProjectSites.ProjectSiteID = DailyNonBuildReviewDeviation.ProjectSiteID
         WHERE 
             [DayOFDeviation] BETWEEN CONVERT(date, @FromDate) AND CONVERT(date, @EndDate))AA
    GROUP BY 
        ProjectSiteName, ProjectSiteID, JobHead, 
        MeasurementPlanned, MeasurementReport, Deviation
END

1 个答案:

答案 0 :(得分:0)

“指定了太多参数。”。您正在从应用程序代码中调用存储过程,该存储过程具有比存储过程中定义的参数更多的参数。确保参数匹配。如果您需要其他帮助,请发布您的应用代码。