Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 168331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:26:03+00:00 2026-05-11T12:26:03+00:00

I have a report made with Crystal Reports 2008 that I need to deploy

  • 0

I have a report made with Crystal Reports 2008 that I need to deploy a production system which means that I need to be able to change the database connection at runtime. The database is PostgreSQL 8.3.0 and the connection I use for creating the initial report is an ODBC connection.

I have found various ways to change the database connection including the following:

reportDoc.Load(report); reportDoc.DataSourceConnections[0].SetConnection('server', 'database', 'user', 'pwd'); reportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); 

However, this always fails with the following error message.

Failed to open the connection.

I have validated the connection parameters by successfully connecting to the database with pgAdmin III so I know the connection parameters are correct. In addition, if I remove the SetConnection(…) line so the code looks like this:

reportDoc.Load(report); reportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); 

then the report runs fine using the connection parameters that are stored in the report. Is it possible that this method does not work for ODBC connections?

How do I change a Crystal Report’s ODBC database connection at runtime?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:26:03+00:00Added an answer on May 11, 2026 at 12:26 pm

    After even more research I found that there was a two part answer.

    PART 1

    If you are connecting to PostgreSQL via ODBC (the only way Crystal Reports can pull data from PostgreSQL as of the time of this writing) using the data owner you then you can use the following code:

    reportDoc.Load(report); reportDoc.DataSourceConnections[0].SetConnection('Driver={PostgreSQL ANSI};Server=myServer;Port=5432;', 'myDatabase', 'myUser', 'myPassword'); reportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); // Depending on your application you may have more than one data source connection that needs to be changed. 

    This method only works if you are connecting as a user that owns the data that you are reporting on because the schema name does not need to be supplied.

    PART 2

    If you are connecting to PostgreSQL via ODBC with a user other than the data owner then you need to manually supply the schema name. This is accomplished with the following code.

    reportDoc.Load(report);  ConnectionInfo connInfo = new ConnectionInfo(); connInfo.ServerName = 'Driver={PostgreSQL ANSI};Server=myServer;Port=5432;'; connInfo.DatabaseName = 'myDatabase'; connInfo.UserID = 'myUser'; connInfo.Password = 'myPassword';  TableLogOnInfo tableLogOnInfo = new TableLogOnInfo(); tableLogOnInfo.ConnectionInfo = connInfo;  foreach (Table table in reportDoc.Database.Tables) {     table.ApplyLogOnInfo(tableLogOnInfo);     table.LogOnInfo.ConnectionInfo.ServerName = connInfo.ServerName;     table.LogOnInfo.ConnectionInfo.DatabaseName = connInfo.DatabaseName;     table.LogOnInfo.ConnectionInfo.UserID = connInfo.UserID;     table.LogOnInfo.ConnectionInfo.Password = connInfo.Password;      // Apply the schema name to the table's location     table.Location = 'mySchema.' + table.Location; }  reportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path); 

    Summary

    There are two critical pieces of information here when trying to connect to a PostgreSQL database from Crystal Reports.

    1. The driver, server, and port number must all be specified in the server name property.
    2. If connecting as a user other than the data owner you must specify the schema name for each table you are pulling data from.

    Sources

    There were several sources used that did not have an answer that worked in my specific scenario but that led me in the right direction. These sources are listed below.

    • Nathan Koop’s Answer
    • https://www.sdn.sap.com/irj/scn/thread?messageID=6913827#6913827
    • Best Practices for Changing Databases at Runtime
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an app which has btn to preview report made in crystal report.
I've made an vb.net application that requires crystal reports 10 and I need to
I have created ASP.net Web application which uses Crystal Report to show reports. Now
I have a report that I run from a system once a week, and
I have a report creator program made in Java that needs to run every
I have made a RDLC report which generates its tablix from the dataset I
I have a report which grabs a whole bunch of statistical data that represent
I have an app that uses both NHibernate and Crystal Reports, NHibernate.dll reference Log4Net
I have made a report that shows transactions in a certain time period for
I have made a servlet from Jasper Reports for Java Develper (chapter 3) which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.