0

プロジェクトを実行すると、エラー出力があります。

error=>パラメータ化されたクエリ '(@IsFilterDates bit,@IsFilterDocumentNumbers bit,@EnterpriseIds' は、指定されていないパラメータ '@FilterFromDocumentNumbers' を予期しています..

私のコード

 public virtual ActionResult GetReportSnapshot()
    {
       var data = (ComparativeBalanceReportDS) Session["ComparativeSession"];
        StiReport report = new StiReport();
        report.Dictionary.DataStore.Clear();
        switch (data.NatureReportIdLevel)
        {
            case 1:
                report.Load(Server.MapPath("~/Content/StimulReports/group.mrt"));
                break;
            case 2:
                report.Load(Server.MapPath("~/Content/StimulReports/total.mrt"));
                break;
            case 3:
                report.Load(Server.MapPath("~/Content/StimulReports/ledger.mrt"));
                break;
            case 4:
                report.Load(Server.MapPath("~/Content/StimulReports/sampr.mrt"));
                if (data.IsNumberFilter != false)
                {
                    report["@FilterFromDocumentNumbers"] = data.NumberFilter.FromDocumentDocumentNumber;
                    report["@FilterToDocumentNumbers"] = data.NumberFilter.ToDocumentDocumentNumber;

                }
                else
                {

                    report["@FilterFromDocumentNumbers"] = null;
                    report["@FilterToDocumentNumbers"] = null;

                }
                             report["@IsFilterDates"] = data.IsDateFilter;
                    report["@IsFilterDocumentNumbers"] = data.IsNumberFilter;
                    report["@EnterpriseIds"] = data.EnterpriseId;
                    report["@FilterFromDates"] = data.DateFilter.FromDocumentDate.Value;
                    report["@FilterToDates"] = data.DateFilter.ToDocumentDate.Value;

                    report["@BaseCompareIds"] = data.BaseCompareId;
                    report["@NatureReportIdLevels"] = data.NatureReportIdLevel;


                break;

        }
and sometimes  some of parameters is null

               report["@FilterFromDates"] = null;
                    report["@FilterToDates"] = null;

SQLでの私の関数

            Create function [dbo].[DetailFunction](@IsFilterDates bit,
                     @IsFilterDocumentNumbers bit,
                     @EnterpriseIds uniqueidentifier,
                     @FilterFromDates datetime,
                     @FilterToDates datetime,
                     @FilterFromDocumentNumbers int= null,
                     @FilterToDocumentNumbers int= null,
                     @BaseCompareIds int,
                     @NatureReportIdLevels int 
                    ) 
      returns @results table (
                      MonthOfDocumentItem nvarchar(20),
                       DetailAccountId nvarchar(50),
                        CreditDebit decimal,
                        Title nvarchar(150)
                                     ) as
    begin

      if @IsFilterDates=1 and @IsFilterDocumentNumbers = 1 and @BaseCompareIds = 2 and @NatureReportIdLevels = 4
      begin       
        insert @results (MonthOfDocumentItem,CreditDebit,DetailAccountId,Title)
        Select  [MonthOfDocumentItem],[CreditDebit],DetailAccountId,Title
        From FilterDetailDocumentItemWithDateAndNumber(@EnterpriseIds,@FilterFromDates,@FilterToDates,@FilterFromDocumentNumbers,@FilterToDocumentNumbers)
      end   
      else if @IsFilterDates=1 and @IsFilterDocumentNumbers = 0 and @BaseCompareIds= 2 and @NatureReportIdLevels = 4
      And @FilterFromDocumentNumbers is null And @FilterToDocumentNumbers is null
      begin       
        insert @results (MonthOfDocumentItem,CreditDebit,DetailAccountId,Title)
        Select  [MonthOfDocumentItem],[CreditDebit],DetailAccountId,Title
        From FilterDetailDocumentItemWithDate(@EnterpriseIds,@FilterFromDates,@FilterToDates)
      end   
      else if @IsFilterDates=0 and @IsFilterDocumentNumbers = 1 and @BaseCompareIds = 2 and @NatureReportIdLevels = 4 
      begin       
        insert @results (MonthOfDocumentItem,CreditDebit,DetailAccountId,Title)
        Select  [MonthOfDocumentItem],[CreditDebit],DetailAccountId,Title
        From FilterDetailDocumentItemWithDocumentNumber(@EnterpriseIds,@FilterFromDocumentNumbers,@FilterToDocumentNumbers)
      end  
      if @IsFilterDates= 0 and @IsFilterDocumentNumbers = 0 and @BaseCompareIds = 2 and @NatureReportIdLevels = 4 

      begin       
        insert @results (MonthOfDocumentItem,CreditDebit,DetailAccountId,Title)
        Select  [MonthOfDocumentItem],[CreditDebit],DetailAccountId,Title
        From FilterDetailDocumentItemWithoutDateAndNumber(@EnterpriseIds)
      end  
      return
              end

Report to exec ストアド プロシージャに null 値を送信するにはどうすればよいですか?

T-SQLで処理するため、一部のパラメーターがnullの場合、ストアドプロシージャは機能しますが、プロジェクトで実行すると機能しません。

4

0 に答える 0