2011-06-03 99 views
0

我正在开发SSRS报告。这是cs文件代码:SSRS报告停止工作

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> 

回答

0

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

编辑:这是因为这些参数有空值。当我将它们的属性设置为允许“”和空值时,它开始工作。

+0

所以你的代码是不是所有... – Episodex 2011-06-06 18:46:12

+0

是啊代码是好的... :) – asma 2011-06-07 04:33:46

+0

啊,我误解了你。您将参数添加到.rdl。如果您在开始时了解这一点,将有所帮助:D。 – Episodex 2011-06-08 10:19:05

0

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

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

如果它不起作用,那么你将不得不使用web.config来正确(正确的入口的例子)。

+0

我的机器没有IIS – asma 2011-06-03 12:18:45

+0

因此它停止在VS的调试模式下工作? – Episodex 2011-06-03 12:23:56

+0

编号VS正在使用ASP.NET开发服务器。 – asma 2011-06-03 12:24:47

0

创建一个ReportViewer &通过标记的LocalReport(如您所知)已被报告有问题的历史记录。

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

那么你的代码中你身后实例化你的ReportViewer和填充本地报告,然后只是:如果你用一个简单的div像更换

<rsweb:ReportViewer>...</rsweb: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) 
     {...} 

现在,很明显,它比这更多,但我所展示的应该会让你更可靠的解决方案。

+0

我不想以这种方式改变任何东西..因为它以前工作非常好 – asma 2011-06-03 12:20:18