Share via


Binding to ReportSource (Crystal Reports Server or BusinessObjects Enterprise 11)

Note

This page describes functionality that is not available in Crystal Reports for Visual Studio, but is available in one of the upgraded versions. For more information about Crystal Reports for Visual Studio, see What is Crystal Reports for Visual Studio? For more information about upgraded versions, see Upgrade Options.

Object Model

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

Location of Reports

Reports are accessed from the Page Server in BusinessObjects Enterprise.

Description

Crystal Reports Server or BusinessObjects Enterprise enables report distribution from servers within an Enterprise framework. A report stored in Crystal Reports Server or BusinessObjects Enterprise can be displayed by different servers at different times, depending on your purpose. In Crystal Reports Server or BusinessObjects Enterprise, if you want to display a report with the best performance possible, and you do not require significant programmatic modification of the report, display your report directly from the Page server with the ReportSource class.

The ReportSource class is not associated with an object model. If you want to modify parameters or database settings, you can use the limited object model provided with the CrystalReportViewer control. However, for more complex programmatic interaction with the report, use one of the other Crystal Reports Server or BusinessObjects Enterprise report binding scenarios.

Note

For a comparison of several scenarios that use different servers in Crystal Reports Server or BusinessObjects Enterprise, see the recommended binding scenarios for Crystal Reports Server or BusinessObjects Enterprise under Summary of Recommended Scenarios.

Pros

  • Fastest: offers best performance for displaying a report out of Crystal Reports Server or BusinessObjects Enterprise.

Cons

  • Limited object model: programmatic modification of database logon or parameter settings are limited to the CrystalReportViewer object model. See Summary of Recommended Scenarios for alternative report binding scenarios that use Crystal Reports Server or BusinessObjects Enterprise.
  • Limited availability: this scenario is only available in Crystal Enterprise version 10, Crystal Reports Server or BusinessObjects Enterprise 11.

Binding the CrystalReportViewer control to a report that is served out of the Crystal Reports Server or BusinessObjects Enterprise Page Server

  • Crystal Reports Server or BusinessObjects Enterprise is installed and verified to be working.

  • Crystal Reports Server or BusinessObjects Enterprise SDK (including the .NET assemblies) is installed and verified to be working.

    Note

    If you have installed Crystal Reports Server or BusinessObjects Enterprise on your development machine, the SDK is included with that installation.

  1. Locate and write down the name of a Crystal Reports Server or BusinessObjects Enterprise server. For purposes of this example, the server name is "BOE01."
1.  To find the server name, right-click the My Computer icon, and then select Properties.
2.  On the System Properties dialog box, click the Network Identification tab.
3.  The computer name is in the "Full computer name" field.
  1. Use the Publishing Wizard to publish the Chart.rpt to the Crystal Reports Server or BusinessObjects Enterprise server. The report file is located in the Feature Examples subdirectory, see Sample Reports' Directory.
> [!NOTE]
> <P>To learn how to use the Publishing Wizard, see the Crystal Reports Server or BusinessObjects Enterprise User documentation.</P>
  1. Add the following assembly references to your project:

    • CrystalDecisions.Enterprise.Framework
    • CrystalDecisions.Enterprise.InfoStore
    • CrystalDecisions.Enterprise.Viewing.ReportSource
    • CrystalDecisions.ReportAppServer.Controllers
  2. From the View menu, click Code to view the code-behind class for this Web or Windows Form. Above the class, add an "Imports" [Visual Basic] or "using" [C#] statement for the CrystalDecisions.Enterprise namespace.

``` vb
Imports CrystalDecisions.Enterprise
Imports CrystalDecisions.Enterprise.Viewing
Imports CrystalDecisions.ReportAppServer.Controllers
```

``` csharp
using CrystalDecisions.Enterprise;
using CrystalDecisions.Enterprise.Viewing;
using CrystalDecisions.ReportAppServer.Controllers;
```

You are now ready to write code that logs on to Crystal Reports Server or BusinessObjects Enterprise.

To logon to Crystal Reports Server or BusinessObjects Enterprise

  1. Within the ConfigureCrystalReports() method (that you have created in Project Setup ), declare a serverName string variable and set it to the name of the Crystal Reports Server or BusinessObjects Enterprise server.
``` vb
Dim serverName As String = "BOE01"
```

``` csharp
string serverName = "BOE01";
```
  1. Declare and instantiate the SessionMgr class.

    Dim mySessionMgr As SessionMgr = New SessionMgr()
    
    SessionMgr sessionMgr = new SessionMgr();
    
  2. Pass the user name (Administrator), the password (blank), the serverName variable, and the logon type (secEnterprise) to the Logon method of the SessionMgr instance and retrieve it as an instance of EnterpriseSession.

``` vb
Dim myEnterpriseSession As EnterpriseSession = mySessionMgr.Logon( _
        "Administrator", "", serverName, "secEnterprise")
```

``` csharp
EnterpriseSession enterpriseSession = sessionMgr.Logon(
      "Administrator", "", serverName, "secEnterprise");
```
  1. Retrieve the InfoStore service (as EnterpriseService), from the GetService method of EnterpriseSession.
``` vb
Dim myEnterpriseService As EnterpriseService = _
        myEnterpriseSession.GetService("InfoStore")
```

``` csharp
EnterpriseService enterpriseService = enterpriseSession.GetService("InfoStore");
```
  1. Declare and instantiate InfoStore and pass in the retrieved EnterpriseService as a parameter to InfoStore.
``` vb
Dim myInfoStore As InfoStore = New InfoStore(myEnterpriseService)
```

``` csharp
InfoStore infoStore = new InfoStore(enterpriseService);
```

You are now ready to retrieve the Hierarchical Grouping report from Crystal Reports Server or BusinessObjects Enterprise.

To retrieve the Hierarchical Grouping report from Crystal Reports Server or BusinessObjects Enterprise

  1. To re-assign the value of the EnterpriseService instance to the Page Server report factory service, pass the "PSReportFactory" string to the GetService() method of EnterpriseService.
``` vb
myEnterpriseService = myEnterpriseSession.GetService("PSReportFactory")
```

``` csharp
enterpriseService = enterpriseSession.GetService("PSReportFactory");
```
  1. Return the Interface property of the EnterpriseService as an object variable.
``` vb
Dim psrfObject As Object = myEnterpriseService.Interface
```

``` csharp
Object psrfObject = enterpriseService.Interface;
```
  1. Cast the object variable to a PSReportFactory instance.
``` vb
Dim myPSReportFactory As PSReportFactory = CType(psrfObject, PSReportFactory)
```

``` csharp
PSReportFactory psReportFactory = (PSReportFactory)psrfObject;
```
  1. Enter the query string below to query Crystal Reports Server or BusinessObjects Enterprise for the report.

    Dim queryString As String = "Select SI_ID, SI_NAME, SI_PARENTID From CI_INFOOBJECTS " _
                    & "Where SI_PROGID='CrystalEnterprise.Report' " _
                    & "And SI_NAME Like 'Chart'"
    
    string queryString = "Select SI_ID, SI_NAME, SI_PARENTID From CI_INFOOBJECTS "
       + "Where SI_PROGID='CrystalEnterprise.Report' "
       + "And SI_NAME Like 'Chart'";
    
  2. Pass the query string to the Query method of InfoStore, to retrieve an InfoObjects indexed class that contains the query result.

``` vb
Dim myInfoObjects As InfoObjects = myInfoStore.Query(queryString)
```

``` csharp
InfoObjects infoObjects = infoStore.Query(queryString);
```
  1. Retrieve the InfoObject from the first column of the InfoObjects indexed class.
``` vb
Dim myInfoObject As InfoObject = myInfoObjects(1)
```

``` csharp
InfoObject infoObject = infoObjects[1];
```
  1. Declare and populate a ReportSource instance from the OpenReportSource() method of the PSReportFactory instance, passing in the ID property of the InfoObject.
``` vb
Dim myReportSource As ReportSource = myPSReportFactory.OpenReportSource(myInfoObject.ID)
```

``` csharp
ReportSource reportSource = psReportFactory.OpenReportSource(infoObject.ID);
```
  1. Bind the ReportSource instance to the ReportSource property of the CrystalReportViewer control.
``` vb
myCrystalReportViewer.ReportSource = myReportSource
```

``` csharp
crystalReportViewer.ReportSource = reportSource;
```
  1. To view the report, build and run your project.
The report is now displayed from the Page Server within Crystal Reports Server or BusinessObjects Enterprise based on its ID. If you use an alternative method to access the reportID (for example, choosing the id from a list of reports in a DropDownList control), you won't need to query the InfoStore and generate an InfoObject to retrieve the reportID.

See Also