如何调试在我的应用程序中不起作用的服务器端 (.rdl) 报表



我有一个承载一堆报表的SQL Server报表服务器(SSRS)。当我单击提供的 URL 时,我可以导航到报表,向下钻取路径,并且可以通过向报表传递所需的参数来成功运行报表。报表使用的存储过程承载在使用 Windows 身份验证的数据库中。

但是,当我尝试从我的应用程序调用相同的报告时,我看不到任何内容。

这是我使用的代码。单击按钮后,我执行以下代码:

var reportViewer = new ReportViewer();
// Set Processing Mode
reportViewer.ProcessingMode = ProcessingMode.Remote;
// Set report server and report path
reportViewer.ServerReport.ReportServerUrl = new Uri("http://MySsrsServer/reportserver");
reportViewer.ServerReport.ReportPath = "/Reports/MyReport";
// set the credentials
reportViewer.ServerReport.ReportServerCredentials.ImpersonationUser = WindowsIdentity.GetCurrent();
// create report parameters and set them in the report
var param1 = new ReportParameter("First_Param", "Some string");
var param2 = new ReportParameter("Second_Param", "Some other string");
reportViewer.ServerReport.SetParameters(new ReportParameter[] { param1, param2 });

using (var reportForm = new ReportForm(reportViewer))
{
   reportForm.ShowDialog();
}
报表窗体

只是具有报表查看器类型的成员的常规窗体。在类构造函数中,我分配成员:

public ReportForm(ReportViewer reportViewer)
{
   InitializeComponent();
   try
   {
      this.reportViewer = reportViewer;
      reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
      reportViewer.Dock = DockStyle.Fill;
      reportViewer.ZoomMode = ZoomMode.Percent;
      reportViewer.ZoomPercent = 100;
      reportViewer.RefreshReport();
   }
   catch (Exception exception)
   {
      MessageBox.Show(exception.Message);
   }
}

正如我所说,我可以看到报告从服务器正确执行,但不能从我的应用程序正确执行。报告表单的内容是空的,但我没有得到任何异常。

知道我做错了什么吗?

TIA,E

事实证明,在要显示报表的窗体外部构造 ReportViewer 对象,然后将其传递到窗体的构造函数中,以便将其分配给内部 ReportViewer 对象并不是一个好主意。我不知道幕后发生了什么,也许 ReportViewr 实例和用于显示报表的 GUI 控件之间的某些绑定已损坏。

最新更新