绑定到 Crystal Enterprise (Crystal Reports 9)

Note注意

本页描述了在 Crystal Reports for Visual Studio 中未提供但在升级版本中提供的功能。若需更多有关 Crystal Reports for Visual Studio 的信息,请参见“什么是 Crystal Reports for Visual Studio?”有关升级版本的更多信息,请参见“升级选项”。此方案仅对 Crystal Reports 9 有效。

此绑定方案使用旧版技术,是为已安装 Crystal Enterprise 的用户设计的。Crystal Enterprise 已被 Crystal Reports Server 和 BusinessObjects Enterprise 替代。有关 Crystal Reports Server 和 BusinessObjects Enterprise 的更多信息,请参见“升级选项”

对象模型

此报表绑定方案使用“通过 CrystalReportViewer 对象模型进行报表绑定”

报表的位置

报表位于托管 RAS 服务器(请参阅“报表应用程序服务器(RAS)”)上。报表包装在 EnterpriseReportDocument 类中。

Crystal 服务概述

此报表绑定方案适用于从服务器资源管理器中的“Crystal 服务”服务器节点访问的报表。

Note注意

有关 Crystal 服务的概述,请参见“使用 Crystal 服务”

本节研究 Crystal Reports 9 中 Crystal 服务的“Crystal Enterprise”子节点。

[服务器名]

  • Crystal 服务
    • Crystal Enterprise

说明

“Crystal Enterprise”子节点访问由 Crystal Enterprise 中的托管 RAS 服务器提供的报表,并随后显示这些报表。

将报表从“Crystal 服务”>“Crystal Enterprise”节点拖放到 Web 或 Windows 窗体上后,会生成 EnterpriseReportDocument 的一个实例。EnterpriseReportDocument 类起一个包装类的作用。它用于包装(表示)从托管 RAS 传出的报表。

在 Crystal Reports 10 中,此绑定方案被以下报表绑定方案替换:

有关 Crystal 服务的比较表格,请参见以下章节之一:

优点

  • 访问简便:便于从 Web 或 Windows 应用程序访问托管 RAS 报表。

缺点

对于对象模型交互,此模型并不特别有效:

  • EnterpriseReportDocument(包装类)仅用于将报表传入和传出托管 RAS 服务器,而不包含对象模型。
  • 因此,这个绑定方案仅提供 CrystalReportViewer 中包含的受限对象模型。请参见“应该使用哪种对象模型?”

有关 RAS 报表绑定的最佳解决方案,请参见“使用 ReportDocument.Load() 方法绑定到非托管 RAS”

使用“Crystal 服务”>“Crystal Enterprise”

  • 已安装 Crystal Reports 9,并且经验证可以正常工作。
  • 已安装 Crystal Enterprise 并已验证其可正常工作。
  • 安装了 Crystal Enterprise SDK(包括 .NET 程序集),并且经验证可正常工作。
    Note注意

    如果在开发计算机上安装了 Crystal Enterprise,则该安装中已经包括 SDK。

此过程仅适用于已通过“项目设置”创建的项目。“项目设置”包含此过程需要的特定命名空间引用和代码配置。如果没有该配置,将无法完成此过程。因此,在开始此过程之前,必须首先执行“项目设置”中的步骤。

  1. 在 Visual Studio 中,打开“服务器资源管理器”。

  2. 展开“Crystal 服务”,然后展开“Crystal Enterprise”。

<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>只有在安装了 Crystal Enterprise 后,“Crystal Enterprise”节点才能正常工作。</p></td>
</tr>
</tbody>
</table>
  1. 从“Crystal Enterprise”树中选择一个报表,并将其拖动到 Web 或 Windows 窗体上。
在设计视图窗体的底部,将出现一个 enterpriseReportDocument1 对象。

当在设计器生成的代码区域实例化并配置从 System.ComponentModel.Component 继承的类(例如 EnterpriseReportDocument)时,此实例化类的图标显示在“设计”视图中窗体的底部。

<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>将 Crystal Enterprise 报表放到窗体上后,会在设计器生成的代码区域中添加 EnterpriseReportDocument 类的一个实例。</p></td>
</tr>
</tbody>
</table>
  1. 切换到代码视图并打开“Web 窗体设计器生成的代码”区域或“Windows 窗体设计器生成的代码”区域。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>已在此区域内实例化并配置了一个 EnterpriseReportDocument 类。</p></td>
</tr>
</tbody>
</table>
  1. 在 ConfigureCrystalReports() 方法(在“项目设置”中创建)中,将 EnterpriseReportDocument 实例赋给 CrystalReportViewer 控件的 ReportSource 属性。

    myCrystalReportViewer.ReportSource = enterpriseReportDocument1
    
    crystalReportViewer.ReportSource = enterpriseReportDocument1;
    
  2. 若要查看该报表,请生成并运行您的项目。