Consultor Eletrônico



Kbase P48972: Crystal Reports 9 Runtime fails with ODBC errors
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/26/2004
Status: Verified

FACT(s) (Environment):

Progress 9.1D

SYMPTOM(s):

Crystal Reports 9 Runtime fails with ODBC errors

Crystal Reports 9

Using LogOnServer method in code

Different error messages dependent on the report being run

Using LogOnServer with DATABASE attribute specified:
Report A fails with error "Insufficient information to connect to the datasource."
Report B works as intended

Using method: <CRAppHandle>:LogOnServer("<DLLName>","<ODBC DSN Name>","<DatabaseName>","<Username>","<Password>")

Results in error:
Login failed
Details:S1000:[DataDirect-Technologies][ODBC PROGRESS driver]: Insufficient information to connect to the datasource.

Using LogOnServer without DATABASE attribute specified:
Report A works as intended
Report B fails with error "Invalid attribute in connection string: DATABASE.

Using method: <CRAppHandle>:LogOnServer("<DLLName>","<ODBC DSN Name>","","<Username>","<Password>")

Results in error:
Login failed
Details:01S00:[DataDirect-Technologies][ODBC PROGRESS driver]: Invalid attribute in connection string: DATABASE.

Errors are reflected in the ODBC Trace Log

Checking report Connection Properties shows that Report A has the following attributes set:
DSN, User ID

Checking report Connection Properties shows that Report B has the following attributes set:
DSN, User ID, Database, Host, Port

CAUSE:

Merant ODBC driver does not seem to handle the DatabaseName parameter of the LogOnServer method.

Because Report B has the Database attribute saved in it, the DatabaseName attribute of the LogOnServer method must also be specified.
However, this means that reports that do not have the Database attribute will not run.

FIX:

To run reports with and without the Database attribute, check the next example code:

DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chTable AS COM-HANDLE NO-UNDO.

CREATE "CrystalRuntime.Application" chApplication.
CREATE "CrystalRuntime.Report" chReport.
chReport = chApplication:OpenReport("<ReportName>",1).
chTable = chReport:Database:Tables(1).

/* Next sentence will remove the Database attribute if it is present in the Connection Properties saved with a report. */

IF INDEX(REPLACE(chTable:ConnectBufferString, ";;", ";"), "Database=") > 0 THEN
chTable:ConnectionProperties:ITEM("DATABASE") = "".

chApplication:LogOnServer("p2sodbc.dll":U, "<ODBC DSN Name>", "", "<Username>":U, "<Password>":U).

RELEASE OBJECT chTable.
RELEASE OBJECT chApplication.
RELEASE OBJECT chReport.