Reporting Services上的内部连接错误

时间:2011-08-19 01:40:22

标签: linq-to-sql reporting-services

嗨我在尝试在我的网页上加载mg报告时遇到了不同的错误。我正在使用报表查看器,我正在使用linq传递参数..附件是代码和错误。

报告处理期间发生错误。 内部连接致命错误。

报告处理期间发生错误。 无法读取数据集SummaryReport的下一个数据行。 内部连接致命错误。

ReportGenerationBL report_worker = new ReportGenerationBL();
        IEnumerable<ART.Library.Data.SummaryReport> items=report_worker.getSummaryReport();

        rpt_view.Reset();


        ReportDataSource[] reportds = new ReportDataSource[2];
        reportds[0] = new ReportDataSource("RenewableObj", report_worker.getRenewablePackage());
        reportds[1] = new ReportDataSource("SummaryReport", items.Where(a=>a.Title!="No Status"));

        List<ReportParameter> paramList = new List<ReportParameter>();

        paramList.Add(new ReportParameter("p_OldPlanAwaiting", items.Where(a => a.Title == "No Status" && a.Category == 0).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_OldPlanRenewable", items.Where(a => a.Title != "No Status" && a.Category == 0).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_OldPlanRenewed", items.Where(a => a.Title != "No Status" && a.Category == 0 && a.Renewed == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_OldPlanRenewedMSF2", items.Where(a => a.Title != "No Status" && a.Category == 0 && a.Renewed == 1).Sum(a => a.MSFOldPlans).ToString()));

        paramList.Add(new ReportParameter("p_VoiceAwaiting", items.Where(a => a.Title == "No Status" && a.Category == 3).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_VoiceRenewable", items.Where(a => a.Title != "No Status" && a.Category == 3).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_VoiceRenewed", items.Where(a => a.Title != "No Status" && a.Category == 3 && a.Renewed == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_VoiceRenewedMSF", items.Where(a => a.Title != "No Status" && a.Category == 3 && a.Renewed == 1).Sum(a => a.MSFVoiceOnly).ToString()));

        paramList.Add(new ReportParameter("p_NoVoiceAwaiting", items.Where(a => a.Title == "No Status" && a.Category == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_NoVoiceRenewable", items.Where(a => a.Title != "No Status" && a.Category == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_NoVoiceRenewed", items.Where(a => a.Title != "No Status" && a.Category == 1 && a.Renewed == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_NoVoiceRenewedMSF", items.Where(a => a.Title != "No Status" && a.Category == 1 && a.Renewed == 1).Sum(a => a.MSFNoVoice).ToString()));

        paramList.Add(new ReportParameter("p_WithOthersAwaiting", items.Where(a => a.Title == "No Status" && a.Category == 2).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_WithOthersRenewable", items.Where(a => a.Title != "No Status" && a.Category == 2).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_WithOthersRenewed", items.Where(a => a.Title != "No Status" && a.Category == 2 && a.Renewed == 1).Sum(a => a.Counter).ToString()));
        paramList.Add(new ReportParameter("p_WithOthersRenewedMSF", items.Where(a => a.Title != "No Status" && a.Category == 2 && a.Renewed == 1).Sum(a => a.MSFWithVoice).ToString()));


        rpt_view.LocalReport.DataSources.Add(reportds[0]);
        rpt_view.LocalReport.DataSources.Add(reportds[1]);
        rpt_view.LocalReport.ReportPath = "PrintFile/SummaryReport.rdlc";
        rpt_view.LocalReport.SetParameters(paramList);
        rpt_view.DataBind();

请帮帮我..

用于获取db中sql函数的getsummary的代码。

 public IEnumerable<SummaryReport> getSummaryReport()
   {
       IEnumerable<SummaryReport> items = from a in ARTDB.func_SummaryReport()
                                          select new SummaryReport { Counter = TryParse.TryParseInt(a.counter), Status = a.status, Title = a.title, SortNo = TryParse.TryParseInt(a.sortno), Category = TryParse.TryParseInt(a.category), Renewed = a.renewed ,MSFNoVoice = a.msfnovoice,MSFOldPlans = a.msfoldplans, MSFVoiceOnly = a.msfvoiceonly, MSFWithVoice = a.msfwithvoice};
       return items;
   }

它已经调用了存储在数据库中的函数..这里是设计器中的代码。

public IQueryable<func_SummaryReportResult> func_SummaryReport()
    {
        return this.CreateMethodCallQuery<func_SummaryReportResult>(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));
    }

1 个答案:

答案 0 :(得分:0)

之前我没有使用DataContext.CreateMethodCallQuery,但我猜它使用了延迟执行。尝试在items.ToList()中返回getSummaryReport()

public IEnumerable<SummaryReport> getSummaryReport()
   {
       IEnumerable<SummaryReport> items = from a in ARTDB.func_SummaryReport()
                                          select new SummaryReport { Counter = TryParse.TryParseInt(a.counter), Status = a.status, Title = a.title, SortNo = TryParse.TryParseInt(a.sortno), Category = TryParse.TryParseInt(a.category), Renewed = a.renewed ,MSFNoVoice = a.msfnovoice,MSFOldPlans = a.msfoldplans, MSFVoiceOnly = a.msfvoiceonly, MSFWithVoice = a.msfwithvoice};
       return items.ToList(); // <-- here
   }