Feedback
Did this article resolve your question/issue?

   

Article

How to use a DSN-less connection with the Crystal Reports ActiveX Automation components in ABL

« Go Back

Information

 
TitleHow to use a DSN-less connection with the Crystal Reports ActiveX Automation components in ABL
URL NameP115877
Article Number000154611
EnvironmentProduct: Progress
Version: 9.1D, 9.1E
Product: OpenEdge
Version: All supported versions
OS: Windows
Other: Crystal Reports 9, 10, XI, XIR2, Crystal Reports ActiveX Runtime
Question/Problem Description
How to use a DSN-less connection with the Crystal Reports ActiveX Automation components in ABL.
Is it possible to specify a connection string rather than a ODBC DSN to connect the Crystal Reports ActiveX Automation components to a Progress database?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
One drawback of calling a Crystal report programmatically is that the name of the ODBC DSN must be known in advance. By using a DSN-less connection or Connection String, an ODBC DSN is no longer even necessary. The only requirement is having a Progress SQL-92 ODBC driver installed on the PC.

1) Start AppBuilder and create a new window


2) Click the OCX button in the AppBuilder Palette and add the appropriate viewer control depending upon the version of Crystal Reports that is being used:

Crystal Report Viewer Control 9 - Crystal Reports 9
Crystal ActiveX Report Viewer Control 10.0 - Crystal Reports 10
Crystal ActiveX Report Viewer Control 11.0 - Crystal Reports 11


3) Add a button, copy the following code into the CHOOSE trigger of the button; the sections of the code that need to be replaced have been highlighted.

Please be aware that the default name of the control changes between Crystal Reports 9 and Crystal Reports 10/11.
For Crystal Reports 9, replace <Control Name> with CRViewer9
For Crystal Reports 10 or Crystal Reports 11, replace <Control Name> with CrystalActiveXReportViewer



/* Sample Code - ConnectionProperties  - Crystal Reports Viewer Control */
DEFINE VARIABLE i AS INTEGER    NO-UNDO.
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport      AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chConnProps   AS COM-HANDLE NO-UNDO.
 
CREATE 'CrystalRuntime.Application' chApplication.
CREATE 'CrystalRuntime.Report'      chReport.
 
/* Insert full path to the Crystal report */
chReport = chApplication:OpenReport("<FullPathToReport>").
 
/* Set the Connection Info to Connection Properties for each table object in the report */
DO i = 1 TO chReport:Database:Tables:Count:
    chConnProps = chReport:Database:Tables(i):ConnectionProperties.

    /* Clear the ConnectionProperties collection */
    chConnProps:DeleteAll.

    /* Add the Connection String for the report - no other connection parameters are required; sample connection strings are included below */
    chConnProps:ADD("Connection String", "DRIVER=<ODBC Driver Name>;HOST=<Hostname>;PORT=<Port>;DB=<Database Name>;UID=<Username>;PWD=<Password>;DIL=<DEFAULT ISOLATION LEVEL>").

    /* Use either of the following statements to override the Catalog name if the report has been created using OpenEdge 10.1B or later - see P122620 for more information*/
    /* chReport:Database:Tables(i):Location = "<Database Name>". */
    /* chReport:Database:Tables(i):SetTableLocation("<Database Name>","",""). */


    RELEASE OBJECT chConnProps .
    chConnProps = ?.
END.
 
/* Set the report source */
chCtrlFrame:<Control Name>:ReportSource = chReport.
 
/* View the report */
chCtrlFrame:<Control Name>:ViewReport().
 
RELEASE OBJECT chReport.
RELEASE OBJECT chApplication.

ASSIGN chReport = ?
               chApplication = ?
               chApplication = ?.
Workaround
Notes
Last Modified Date9/13/2015 4:18 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.