Kbase P47202: Crystal Reports: How to change the ODBC DSN connection at runtime?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/05/2006 |
|
Status: Verified
GOAL:
How to change the ODBC DSN connection at runtime?
GOAL:
How to change the ODBC DSN connection at runtime when using the LogOnServer method?
FACT(s) (Environment):
Progress 9.1D
Progress 9.1E
OpenEdge 10.x
Crystal Reports 9
Crystal Reports 10
Crystal Reports 11 (XI)
FIX:
One possible way is to use the ConnectionProperties property to change the DSN for the report and then use the LogOnServer method to set the other connection parameters.
Following is a *simplified* example:
/*** Beginning of example ***/
DEFINE VARIABLE crApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE crReport AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE crTable AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE DSN AS CHARACTER NO-UNDO.
CREATE "CrystalRuntime.Application" crApplication.
CREATE "CrystalRuntime.Report" crReport.
/* Define the DSN name here */
DSN = "sports2000".
crReport = crApplication:OpenReport("report.rpt",1).
crTable = crReport:Database:Tables(1).
crTable:ConnectionProperties:ITEM("DSN") = DSN.
crApplication:LogOnServer("CRDB_ODBC.DLL",
DSN,
"",
"pub",
"pub").
RELEASE OBJECT crTable.
RELEASE OBJECT crReport.
RELEASE OBJECT crApplication.
/*** End of example ***/