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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 247k
  • Answers 248k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Programming something in TeX that isn't a document: A BASIC… May 13, 2026 at 8:46 am
  • Editorial Team
    Editorial Team added an answer I wouldn't have thought there'd be any reason for them… May 13, 2026 at 8:46 am
  • Editorial Team
    Editorial Team added an answer What you're looking for is probably KML. Its pretty easy… May 13, 2026 at 8:46 am

Related Questions

I'm in the process of upgrading an existing ASP.NET2.0 application to .NET3.5 (moving from
I'm using Oracle SQL Developer to query an Oracle DB (not sure which version
I have a report which on execution connects to the database with my_report_user username.
I made a report with about 30 different rectangles and textboxes that have different

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.