SSRS报告停止工作

时间:2011-06-03 11:58:43

标签: asp.net reporting-services rdlc

我正在研究SSRS报告。这是cs文件代码:

new protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String reportTitle = GetValueFromQueryString("ReportTitle");
            /* Get Agency name and set it in report parameters */
            AgencyBO agencyBO = new AgencyBO();
            Agency agency = new Agency();
            agency = agencyBO.GetAgencyInformation();
            List<ReportParameter> lstParam = new List<ReportParameter>();
            lstParam.Add(new ReportParameter("Agency", agency.Name));

            /* Declare parameters that are to be sent to Report Helper class */
            string orderBy = string.Empty,
                   startAge = string.Empty,
                   endAge = string.Empty,
                   sex = string.Empty,
                   staffId = string.Empty,
                   statusId = string.Empty,
                   ethnicityId = string.Empty,
                   treatmentProviderId = string.Empty;

            ConsumerSummaryReportCriteria consumerSummaryReportCriteria = new ConsumerSummaryReportCriteria();
            Dictionary<String, String> lst = consumerSummaryReportCriteria.GetReportParams();
            foreach (var pair in lst)
            {
                /* ---- Set parameters that are to be sent to Report Helper class ---- */
                if (pair.Key == "orderBy" && pair.Value != string.Empty)
                {
                    orderBy = pair.Value;
                }
                if (pair.Key == "startAge" && pair.Value != string.Empty)
                {
                    startAge = pair.Value;
                    lstParam.Add(new ReportParameter("startAge", pair.Value));
                }
                if (pair.Key == "endAge" && pair.Value != string.Empty)
                {
                    endAge = pair.Value;
                    lstParam.Add(new ReportParameter("endAge", pair.Value));
                }
                if (pair.Key == "gender" && pair.Value != string.Empty)
                {
                    sex = pair.Value;
                    lstParam.Add(new ReportParameter("gender", pair.Value));
                }
                if (pair.Key == "staffIds" && pair.Value != string.Empty)
                {
                    staffId = pair.Value;
                }
                if (pair.Key == "consumerStatusIds" && pair.Value != string.Empty)
                {
                    statusId = pair.Value;
                }
                if (pair.Key == "ethnicityIds" && pair.Value != string.Empty)
                {
                    ethnicityId = pair.Value;
                }
                if (pair.Key == "treatmentProviderIds" && pair.Value != string.Empty)
                {
                    treatmentProviderId = pair.Value;
                }

                /* ---- Set parameters to report parameters list that are to be sent to 
                 * RDLC to show report selection criteria at the end of the report ---- */
                if (pair.Key == "staffNames")
                {
                    lstParam.Add(new ReportParameter("staffNames", pair.Value));
                }
                if (pair.Key == "consumerStatusNames")
                {
                    lstParam.Add(new ReportParameter("consumerStatusNames", pair.Value));
                }
                if (pair.Key == "treatmentProviderNames")
                {
                    lstParam.Add(new ReportParameter("treatmentProviderNames", pair.Value));
                }
                if (pair.Key == "ethnicityNames")
                {
                    lstParam.Add(new ReportParameter("ethnicityNames", pair.Value));
                }
            }

            ReportHelper.ApplyReportSetting(ref rptConsumerSummaryReport, reportTitle, orderBy, startAge, endAge, sex, staffId, statusId, ethnicityId, treatmentProviderId);

            rptConsumerSummaryReport.LocalReport.SetParameters(lstParam);
            rptConsumerSummaryReport.LocalReport.Refresh();
        }
    }

它工作得很好但突然停止工作。 将打开一个空白的aspx页面,并且报表查看器无法打开。

这是aspx文件的代码。

<form id="frmConsumerSummaryReport" runat="server">
<div>
    <asp:ScriptManager ID="scmReport" runat="server">
    </asp:ScriptManager>
    <rsweb:ReportViewer ID="rptConsumerSummaryReport" runat="server" Height="100%" AsyncRendering="False"
        Width="100%" SizeToReportContent="True" Font-Names="Verdana" 
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportPath="Reports\Consumer\ConsumerSummaryReport.rdlc">
        </LocalReport>
    </rsweb:ReportViewer>
</div>
</form>

3 个答案:

答案 0 :(得分:0)

试试这个:http://otkfounder.blogspot.com/2007/11/solving-reportviewer-rendering-issue-on.html

如果您没有更改代码或报告,则可以使用IIS配置。这个链接帮助我解决了这类问题两次以上。首先确保你已经添加了描述的处理程序。如果没有,添加它并测试它是否有效。

如果它不起作用,那么你必须使用web.config才能正确使用(正确输入的例子就在那里)。

答案 1 :(得分:0)

创建ReportViewer&amp;据报道,通过标记的LocalReport(正如你所知)有问题的历史。如果替换

,您将获得更好的结果

<rsweb:ReportViewer>...</rsweb:ReportViewer>

有一个简单的div:

<div id='reportContainer' runat='server'></div>

然后在您的代码中,您实例化您的ReportViewer并填充本地报告,然后将其作为控件添加到div。

在我的报表管理器类中,对div的引用是构造函数的一部分,如:

public ReportManager(HtmlContainerControl ReportContainer){...}

导致'showTeport方法'只是将观众放入其中......就像...

private ReportViewer ShowReport(string ReportName, DataSet ds)
   {
      try
      {
         _activeDS = ds;
         string ReportFileName = ResolveRDLCName(ReportName);
         var viewer = new ReportViewer();

         viewer.LocalReport.ReportPath = ReportFileName;
         viewer.LocalReport.EnableHyperlinks = true;

         //AssignReportParameters(viewer.LocalReport);

         foreach (DataTable dt in ds.Tables)
         {
            viewer.LocalReport.DataSources.Add(new ReportDataSource(ds.DataSetName + "_" + dt.TableName, dt));
         }

         viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);

         _ReportContainer.Controls.Add(viewer);

         return viewer;
      }
      catch (FileNotFoundException fnf)
      {...}

现在,显然,它还有很多,但我所展示的应该能让你找到更可靠的解决方案。

答案 2 :(得分:0)

我在报告中停止了工作后添加了一些新参数。不知道为什么会这样。删除这些参数后,它再次正常工作。

编辑:之所以这样,是因为那些参数的值为空。当我将其属性设置为Allow“”和null值时,它开始工作。