Share via


Binding to Server Files (VS .NET 2003)

Object Model

This report binding scenario uses CrystalReportViewer (see Report Binding with CrystalReportViewer Object Model.)

Location of Reports

Reports are in a folder of reports in the local file directory (see Sample Reports' Directory). Reports from this location are exposed as Report Web Services.

Crystal Services Overview

This report binding scenario applies to reports accessed from the Crystal Services server node in the Server Explorer.

Note

For an overview of Crystal Services, see Using Crystal Services.

This section examines the Server Files sub node of Crystal Services, within Visual Studio .NET 2003.

[SERVERNAME]

  • Crystal Services
    • Server Files

Description

The Server Files sub node accesses and then displays reports that have been exposed as Report Web Services from a local file directory. These reports are exposed with the Report Web Services protocol. In Visual Studio .NET 2003, to access Server Files, click the Server Files node under Crystal Services.

For a comparison table of Crystal Services, see CrystalReportViewer Binding Scenarios that Use Crystal Services and ReportDocument Binding Scenarios that Use Crystal Services (VS.NET 2002 and 2003).

The Server Files sub node of Crystal Services is replaced in Crystal Reports 9 and 10 with other Crystal Services sub nodes that connect directly to an Report Application Server (RAS) server, bypassing the Report Web Services protocol:

Pros

  • Central access to reports: provides a single point of access to all reports in your sample reports directory (see Sample Reports' Directory), which creates an effective reports repository on your local hard drive.

Cons

  • Replaced in Crystal Reports 9 and 10 with an unmanaged RAS Crystal Services node. See the Description section above for further details.
  • Limited object model: this binding scenario offers only the limited object model that is part of the CrystalReportViewer. See Which Object Model Should I Use?.

Configuring Server Files

Server Files are provided as a Crystal Services node in Crystal Reports for Visual Studio 2003. When Crystal Reports 9 or 10 (the full versions) are installed on top of the version included with Visual Studio 2003, the Server Files node is removed as a visible node.

Each edition of What is Crystal Reports for Visual Studio? continues to support Server Files in the SDK. However, manual coding is required to work with Server Files in that version.

For detailed instructions on Server Files configuration, see Configuring Server Files in Crystal Services.

To install Crystal Services

You must have Crystal Reports for Visual Studio .Net 2003 installed.

Crystal Services are not installed by default during the Visual Studio .NET 2003 install. In this procedure you will install Crystal Services from the Visual Studio .Net 2003 installation CD.

  1. On your Microsoft Visual Studio .NET installer CD, locate Crystal Reports.
  2. Select Crystal Web Services.
  3. Click the Update button.

To use the Crystal Services>Server Files node

  • Crystal Reports for Visual Studio .NET 2003 is installed and verified to be working.

  • Or, Crystal Reports 9 or greater is installed and verified to be working.

    Note

    In Crystal Reports 9 and 10, Server Files is replaced (it is no longer displayed as a node under Crystal Services). However, you can still code Server Files manually.

Note

This procedure works only with a project that has been created from Project Setup. Project Setup contains specific namespace references and code configuration that is required for this procedure, and you will be unable to complete the procedure without that configuration. Therefore, before you begin this procedure, you must first follow the steps in Project Setup.

  1. From the View menu, click Other Windows, and then Server Explorer.

  2. Expand Crystal Services, and then expand Server Files.

  3. Select a report from the Server Files tree and drag it onto your form.

    Note

    When a Server Files report is placed onto your form, an instance of ServerFileReport class is added to the Designer generated code region of your form.

    When classes that inherit from System.ComponentModel.Component (such as ServerFileReport) are instantiated and configured within the Designer generated code region, an icon of this instantiated class appears at the bottom of the form in Design view.

    At the bottom of the form Design view, a serverFileReport1 object appears.

  4. Switch to code view and open the Web or Windows Form Designer generated code region.

    A ServerFileReport class has been instantiated and configured within this region.

  5. Within the ConfigureCrystalReports() method (that you have created in Project Setup), assign the ServerFileReport instance to the ReportSource property of the CrystalReportViewer control.

    myCrystalReportViewer.ReportSource = serverFileReport1
    
    crystalReportViewer.ReportSource = serverFileReport1;
    

To view the report, build and run your project.

To code the Server Files manually

  • Crystal Reports for Visual Studio .NET 2003 is installed and verified to be working.

  • Or, Crystal Reports 9 or greater is installed and verified to be working.

    Note

    In Crystal Reports 9 and 10, Server Files is replaced (it is no longer displayed as a node under Crystal Services). However, you can still code Server Files manually.

Note

This procedure works only with a project that has been created from Project Setup. Project Setup contains specific namespace references and code configuration that is required for this procedure, and you will be unable to complete the procedure without that configuration. Therefore, before you begin this procedure, you must first follow the steps in Project Setup.

  1. Within the ConfigureCrystalReports() method (that you have created in Project Setup), declare an instance of ServerFileReport.

    Dim myServerFileReport As CrystalDecisions.Shared.ServerFileReport = _
        New CrystalDecisions.Shared.ServerFileReport()
    
    CrystalDecisions.Shared.ServerFileReport serverFileReport = new CrystalDecisions.Shared.ServerFileReport();
    
  2. Set the ObjectType property of the ServerFileReport to REPORT.

    myServerFileReport.ObjectType = CrystalDecisions.[Shared].EnumServerFileType.REPORT
    
    serverFileReport.ObjectType = CrystalDecisions.Shared.EnumServerFileType.REPORT;
    
  3. Set the ReportPath property of the ServerFileReport to the report and it's subdirectory. For information about sample reports, see Sample Reports' Directory.

    myServerFileReport.ReportPath = "\General Business\World Sales Report.rpt"
    
    serverFileReport.ReportPath = "\\General Business\\World Sales Report.rpt";
    
  4. Set the WebServiceURL property of the ServerFileReport to the viewer's virtual directory for your installed version of Crystal Reports, see Viewers' Virtual Directory .

    Note

    In this sample code, the viewers' virtual directory is configured for Crystal Reports 10.

    myServerFileReport.WebServiceUrl = "https://localhost/crystalreportviewers10/ServerFileReportService.asmx"
    
    serverFileReport.WebServiceUrl = "https://localhost/crystalreportviewers10/ServerFileReportService.asmx";
    
  5. Set the ReportSource property of the CrystalReportViewer control to the ServerFileReport instance.

    myCrystalReportViewer.ReportSource = myServerFileReport
    
    crystalReportViewer.ReportSource = serverFileReport1;
    

See Also