Share via


Binding to Server Files (Visual Studio 2005 and up)

Object Model

This report binding scenario uses the CrystalReportViewer Object Model (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.

Server Files Overview

This report binding scenario applies to reports accessed as a Server File through a web service.

Note

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

Description

The Server Files web service accesses and displays reports that have been exposed as Report Web Services from a local file directory. In Visual Studio 2005 and later, Server Files are accessed programmatically.

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).

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

  • 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 accessed programmatically in Crystal Reports for Visual Studio. Each edition of What is Crystal Reports for Visual Studio? continues to have programmatic support for Server Files in the SDK.

For detailed instructions on Server Files configuration, see Configuring Server Files in Visual Studio 2005 or 2008.

To code the Server Files manually

  • A Report Web Service that permits programmatic access to Server Files has been configured and is verified to be working.
  • Or, What is Crystal Reports for Visual Studio? is installed and verified to be working.

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.
``` vb
Dim myServerFileReport As CrystalDecisions.Shared.ServerFileReport = _New CrystalDecisions.Shared.ServerFileReport()
```

``` csharp
CrystalDecisions.Shared.ServerFileReport serverFileReport = new CrystalDecisions.Shared.ServerFileReport();
```
  1. Set the ObjectType property of the ServerFileReport to REPORT.

    myServerFileReport.ObjectType = CrystalDecisions.[Shared].EnumServerFileType.REPORT
    
    serverFileReport.ObjectType = CrystalDecisions.Shared.EnumServerFileType.REPORT;
    
  2. Set the ReportPath property of the ServerFileReport to the report and its 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";
    
  3. Set the WebServiceURL property of the ServerFileReport to the location of the Report Web Service.

    If you have Crystal Reports Developer installed, this will be the viewer's virtual directory for your installed version of Crystal Reports, see Viewers' Virtual Directory. If you do not have Crystal Reports Developer installed, this will be the URL to the Report Web Service that you created in Configuring Server Files in Visual Studio 2005 or 2008.

    Note

    In the code below, the viewers' virtual directory is configured for Crystal Reports for Visual Studio 2005.

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

    myCrystalReportViewer.ReportSource = myServerFileReport
    
    crystalReportViewer.ReportSource = serverFileReport1;
    

See Also