Back to Top

Solution: Failed to Open the Connection

Before The Report Viewer will work on your system, you must setup and configure the database connections that are referenced inside your report. If they are not setup, you will get a "failed to connect message." This is expected and normal. Just takes a bit of work to setup and configure the connections properly. Generally this is done by the person who designs the reports or the person who maintains the database.

Issue

You try to open or refresh data on a report, and get a message box that says "failed to open the connection."

Resolution

The computer has to be configured to connect to the datasource referenced in the report.

Setup the system the same way as the computer used to design the reports. Install the same database drivers (32-bit versions). Give them the same name.

Your report files contain database references.

Screenshot of Crystal Reports Database Expert and Windows 32-bit ODBC Database Administrator

Here are some guidelines:

  • You have to setup the database driver on the client PC (the one with The Report Viewer)
  • The software support most any type of database driver, so guidelines are general. You have to setup the PC and database drivers the same way you would a system with full Crystal Reports.
  • You must use a 32-bit version of the database driver
    • The software works fine on 64-bit systems (using 32-bit database drivers)
    • The 32-bit ODBC database driver is in this location on 64-bit systems: C:\Windows\SysWOW64\odbcad32.exe
  • If using ODBC, the DSN must match the DSN hard coded inside the report file
  • You must configure the database server to allow connections from the client PC. Many database servers will reject connections if their IP, PC, or username isn't explicitly allowed to connect; and they won't tell you why.
  • If you get a connection error with "vendor database error" number, then that number is an error number from your specific database type. Search online for the cause of it. Getting a vendor error means that you are connecting to some database, but perhaps don't have permission to view a specific table or shared procedure.

Setup the computer the same way as the machine that designed the reports; configure the database server to allow connections from the client PC (some databases have security configuration that has to be set for new clients).

Each report references a data source. For example, some reports reference XLS spreadsheets while others reference ODBC database drivers. Some report reference multiple data sources. Each must be setup, and available from the PC using The Report Viewer.

Issue with Hard Coded Paths

Consider the example where an XLS spreadsheet or an MDB database is referenced by your report. If those are values are hard coded paths inside your report (e.g. C:\Path\To\\Docs\Jet.mdb), then that path must be available, as referenced, or you will get a connection error or you could get a username and password prompt.

ODBC as Eloquent Solution

ODBC is a good portable solution. In this case, data sources are referenced by Data Source Name (DSN). So long as a working 32-bit (x86) database driver exist on the system, with the DSN referenced by the report, all will work well.

In this situation, note, The Report Viewer talks to the ODBC database driver, and not directly to the database.

The Report Viewer -> 32-bit (x86) ODBC Database Driver -> Your database

Steps to Configure Data Source Connections

This helps if you are the person who designs the reports and sets up the database servers.

  1. Open the report file or RPT file in a full version of Crystal Reports
  2. Go to the database wizard inspect the following database properties
    • Type of database diver
    • If ODBC, Case Sensitive Data Source Name (DSN)
    • Other, Case Sensitive server, database, or other information needed to setup and configure client PCs for the report
  3. Setup the database connection on the client PC

If it uses an ODBC driver, make sure the DSN installed on the computers 32 bit ODBC driver matches the one references in the report. If the report references a file path, make sure that you have access to that file. If it's SQL Server, you can setup using ODBC, or you can override the connections inside the viewer and enter the datasource directly; it depends on the way the reports are setup. If you override the datasource connections for an ODBC driver, make sure to use the ODBC DSN as both the database and server, since the viewer connects to the ODBC driver and not directly to the server.

If all else fails, configure your computer the same way as the person who builds the reports. Have the person who designs the reports double-check your database connections. Also, ask the person who maintains the database to help out, because database user permissions could cause connection issues.

Configure the Server Too

Your database is secure, right? Well, then when you add new client PCs, you likely have to expressly allow access to the new user, PC, IP address, etc.

Did you get a prompt for a username and password? Then, the server is not responding. Could it be because it doesn't exist as referenced? Or, maybe it's not configured to respond to you... that is it's ignoring you, because of its security directive. Make sure to configure the client PCs, but also configure the servers.

Examples

Make sure to read this detailed example.

You will get this message if someone builds a Crystal Report on their computer that accesses the company’s sales server and a Excel spreadsheet on the local computer. The report is then given to a sales person to run. The viewer on the sales person’s computer won't be able to access the data source in the Excel spread sheet on the managers computer, and it will throw this error.

Another example of a setup that will cause this error is if your data is an XML source on a remote web server, but your computer doesn't have Internet access.

Another example is if your ODBC data source has a different name on the computer that created the report, from the computer that is running the report. In this case, you will want uncheck the check box that says "Use Report Settings," and select the correct connection for the viewer to use.