RDLC 移动到服务器时缺少子报告

发布于 2024-10-15 05:00:12 字数 2111 浏览 3 评论 0原文

我很难使用报表查看器在我的应用程序中显示子报表。本地调试时效果很好。但是当我将其上传到服务器时,子报告是空白的。

我相信 SubreportProcessing 事件不会触发,因为我没有看到 SQL Server Profiler 触发存储过程。这是我正在使用的代码。

private void RunReport(string strFormat, int PlanID)
    {
        const string reportrdlc = "Reports\\Report_All_Sections.rdlc";
        LocalReport report = new LocalReport {ReportPath = Server.MapPath(reportrdlc)};
        report.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
        report.DataSources.Clear();
        report.SubreportProcessing += SetSubDataSource;

        report.DataSources.Add(new ReportDataSource("DataSet_usp_GetSD", _wpt.Get_SD(PlanID).Copy()));

        report.Refresh();

        string mimeType;
        string encoding;
        string fileNameExtension;
        string[] streams;
        Warning[] warnings;

        byte[] pdfContent = report.Render(strFormat, null, out mimeType, out encoding,
                    out fileNameExtension, out streams, out warnings);

        System.IO.MemoryStream stream = new System.IO.MemoryStream(pdfContent);
        Response.ContentType = strFormat == "EXCEL" ? "application/vnd.ms-excel" : "application/pdf";

        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        Response.Close();
        stream.Close();

    }
    public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
    {
        int PlanID = 1;
        if (Request.QueryString["PlanID"] != null)
        {
            try
            {
                PlanID = Convert.ToInt32(Request.QueryString["PlanID"]);
            }
            catch (Exception Ex)
            {
                PlanID = 1;
            }
        }
        switch (e.ReportPath)
        {
            case "Report_All_Mentor":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetMC", _wpt.Get_MC(PlanID).Copy()));
                break;
            case "Report_All_Intern":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetEA", _wpt.Get_EA(PlanID).Copy()));
                break;
        }


    }

I'm having a hard time getting a sub report to show up in my application using reportviewer. It works perfectly when debugging it locally. But when I upload it to the server, the sub reports are blank.

I've believe that SubreportProcessing event is not firing since I don't see the stored procedures getting fired from SQL Server Profiler. Here is my code that I'm using.

private void RunReport(string strFormat, int PlanID)
    {
        const string reportrdlc = "Reports\\Report_All_Sections.rdlc";
        LocalReport report = new LocalReport {ReportPath = Server.MapPath(reportrdlc)};
        report.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
        report.DataSources.Clear();
        report.SubreportProcessing += SetSubDataSource;

        report.DataSources.Add(new ReportDataSource("DataSet_usp_GetSD", _wpt.Get_SD(PlanID).Copy()));

        report.Refresh();

        string mimeType;
        string encoding;
        string fileNameExtension;
        string[] streams;
        Warning[] warnings;

        byte[] pdfContent = report.Render(strFormat, null, out mimeType, out encoding,
                    out fileNameExtension, out streams, out warnings);

        System.IO.MemoryStream stream = new System.IO.MemoryStream(pdfContent);
        Response.ContentType = strFormat == "EXCEL" ? "application/vnd.ms-excel" : "application/pdf";

        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        Response.Close();
        stream.Close();

    }
    public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
    {
        int PlanID = 1;
        if (Request.QueryString["PlanID"] != null)
        {
            try
            {
                PlanID = Convert.ToInt32(Request.QueryString["PlanID"]);
            }
            catch (Exception Ex)
            {
                PlanID = 1;
            }
        }
        switch (e.ReportPath)
        {
            case "Report_All_Mentor":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetMC", _wpt.Get_MC(PlanID).Copy()));
                break;
            case "Report_All_Intern":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetEA", _wpt.Get_EA(PlanID).Copy()));
                break;
        }


    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人九事 2024-10-22 05:00:12

我似乎也有同样的问题。我认为问题在于,部署时 reportPath 包含报告的完整路径,但当您在本地调试时,它仅传递报告名称。

您的 SubreportProcessing 事件是否确实正在触发,但在您的 switch 语句中,没有任何情况与 reportPath 参数中包含的完整路径匹配。

我不知道如何解决这个问题,但我认为这可能是根本原因。

I seem to have the same issue. I believe that the problem is that when deployed reportPath contains the full path for the report, but when you are debugging locally it passes only the report name.

Is it possible that your SubreportProcessing event is indeed firing but in your switch statement non of the cases match the full path contained in the reportPath parameter.

I don't know how to resolve that but I think that might be the root cause.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文