Consultor Eletrônico



Kbase P168097: How to use a DSN-less connection with the Crystal Reports .NET control in a 4GL program.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/06/2010
Status: Unverified

GOAL:

How to use a DSN-less connection with the Crystal Reports .NET control in a 4GL program.

GOAL:

Is it possible to specify a connection string rather than a ODBC DSN to connect the Crystal Reports .NET control to a Progress database?

FACT(s) (Environment):

Windows
OpenEdge 10.1x
Crystal Reports

FIX:

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.
An example of a 4GL program follows:

DEFINE VARIABLE objReport AS CrystalDecisions.CrystalReports.Engine.ReportDocument NO-UNDO.
DEFINE VARIABLE TableConInfo AS CrystalDecisions.Shared.TableLogOnInfo NO-UNDO.
DEFINE VARIABLE crwConnectionInfo AS CrystalDecisions.Shared.ConnectionInfo NO-UNDO.
objReport = NEW CrystalDecisions.CrystalReports.Engine.ReportDocument().
objReport:Load("<Full Path to Report>").
crwConnectionInfo = NEW CrystalDecisions.Shared.ConnectionInfo().
crwConnectionInfo:LogonProperties:Clear().
crwConnectionInfo:ServerName = "DRIVER=<ODBC Driver Name>;HOST= <Hostname>;PORT=<Port>;DB=<Database Name>;UID=<Username>;PWD=<Password>;DIL=<DEFAULT ISOLATION LEVEL> ".
DO i = 0 To objReport:DATABASE:Tables:Count - 1:
TableConInfo = objReport:DATABASE:Tables[i]:LogOnInfo.
TableConInfo:ConnectionInfo = crwConnectionInfo.
objReport:DATABASE:Tables[i]:ApplyLogOnInfo(TableConInfo).
END.