Solving Connection Issues in The Report Viewer: "Failed to open the connection."

Problem

Ever get a "failed to open the connection" message. This will hopefully help you get it sorted out.

Failed to open the connection. Failed to open the connection. Third Party Network Asset v2 (00858646-E5B9-4DE5-99C0-36504E889D5D).rpt System.Runtime.InteropServices.COMException (0x00002F4: Failed to open the connection at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetPage(PageRequestContext pPageRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.GetPage(PageRequestContext pPageRequestContext)

Why Does This Happen?

The Report Viewer is an interface for Crystal Reports.

Crystal Reports is an interface for your database. As such, Crystal Reports and The Report Viewer require a database driver be setup and installed, so that it can connect to the database.

The Basic

There's more to it.

  • The database driver must exist on the PC as referenced inside the report file
    • Database references are hard coded inside Crystal Reports files
      • If the report references an Access .MDB file, then that .MDB file must exist at the path hard coded inside the report
      • If the report references an ODBC database driver, then that driver must exist by the referenced DSN
      • If the report references a SQL Server database, well that database should be configured to allow the client PC to connect
      • If the report references an Oracle database, that database driver needs to be installed, configured, available, and match the version of the Crystal runtime in TRV
    • Database drivers need to be 32 bit versions, to match The Report Viewer
    • They have to be configured correctly... it's good to test them with other software if you get this message
  • The database server must give the client PC and user permission to access the data.
  • The database driver must exist as referenced
Read a detailed walk-through covering ODBC setup.

How to Resolve the Issue

There are two ways to configure the software to connect to the data source.

  1. Using the settings embedded inside the report
  2. Overriding the settings embedded inside the report

Fix Connection Method 1: Using Datasource as Embedded Inside the Report

This is the preferred method. It seems simple in theory.

Simply know the data source that your report references, and setup that data source as referenced inside your report on your system as a 32-bit database driver.

  1. Know the data source that your report references
  2. Setup that data source as referenced inside your report as a 32-bit database driver

An Example

To make things easy, we will use ODBC for the example.

Step One: Verify Data Source Info
You have to open up your report in a full install of Crystal, and look at the report expert. You need to see that it uses ODBC, and you need to find the Data Source Name (DSN).

Step Two: Setup Database Driver
Our reporting software is all currently 32-bit software. So, you must use 32-bit (x86) data source administrators. Funny enough, it's in the following location: ( C:\Windows\SysWOW64\odbcad32.exe ).

Using the 32-bit ODBC administrator, create a database driver with the same data source name referenced inside the report. It must be case sensitive.

Now all should work well. If you have issues, verify your settings and contact us.

Fix Connection Method 2: Overriding the Settings Embedded Inside the Report

Overriding the data source is even more tricky.

You must know the following to get started:

  1. Details of how the database is setup on the client system
  2. Must also know how the reporting engine expect the override data.

This example is connecting a report to the Xtreme sample databases with Crytsal Reports 2008, using the path to the access database. Note the path is hard coded.

To make it more portable, use ODBC.

Then, put the ODBC Data Source Name in BOTH the SERVER and DATABASE field.

Edit Connection: Nickname: Username: Password: Server: Database: SSL: Help