[Migrated content. Thread originally posted on 22 June 2005]
In our new Acucobol application we are developing, we want to interface with Crystal Reports in order to allow clients to create their own reports and run them from within our application (for numerous reasons). We have had no problem doing this up to this point working with ODBC. However, now we want to get it to work with MSDE and MS-SQL databases. That means we need to get properties of the database and login to allow access to the data before calling the Crystal Report to run. We are having difficulties with the properties of the database, and were wondering if anyone had any successful experiences with this. We are developing using AcuBench 5.2.1 and interfacing with Crystal Reports XI.Method 1:
Modifying the connection properties of a database table. Trying to read connection information first, before tackling modifying.
(craxdrt11.def)
* Item
* Gets value by name.
PROPERTY-GET, 0, @Item,
"BSTR" @Name, TYPE 8
RETURNING "VARIANT", TYPE 12
Method 2:
Using the logon method of the database object.
(craxdrt11.def)
* Log on server.
METHOD, 228, @LogOnServer,
"BSTR" @pDllName, TYPE 8,
"BSTR" @pServerName, TYPE 8,
"VARIANT" @pDatabaseName, TYPE 12,
"VARIANT" @pUserID, TYPE 12,
"VARIANT" @pPassword, TYPE 12
OPTIONAL 3
Working Storage:
01 CR-REPORT USAGE HANDLE OF APPLICATION.
01 CR-VIEWER USAGE HANDLE OF CrystalActiveXReportViewer.
01 DATABASE-OBJ USAGE HANDLE OF IDatabase.
01 DB-TABLE-COLL-OBJ USAGE HANDLE OF IDatabaseTables.
01 TABLE-OBJ USAGE HANDLE OF IDatabaseTable.
01 CONNECT-PROP-OBJ USAGE HANDLE OF INameValuePairs.
01 CONNECT-PROP USAGE HANDLE OF IConnectionProperty.
01 VARIANT-VALUE USAGE HANDLE.
01 PROPERTY-VALUE PIC X(25).
01 RETURN-RESULT PIC S9(1).
01 SERVER-NAME PIC X(25).
01 U-ID PIC X(25).
01 U-ID-V USAGE HANDLE.
01 PASSWD PIC X(25).
01 PASSWD-V USAGE HANDLE.
01 DATABASE-NAME PIC X(25).
01 DATABASE-NAME-V USAGE HANDLE.
01 REPORT-PATH PIC X(255).
01 REPORT-OBJ USAGE HANDLE OF REPORT.
Program:
CREATE @APPLICATION OF @CRAXDRT HANDLE IN CR-REPORT
?
Method 1:
INQUIRE DATABASE-OBJ @TABLES
IN DB-TABLE-COLL-OBJ
INQUIRE DB-TABLE-COLL-OBJ @Item(1) IN TABLE-OBJ
INQUIRE TABLE-OBJ @ConnectionProperties
IN CONNECT-PROP-OBJ
INQUIRE CONNECT-PROP-OBJ @Item ("Initial Catalog")
IN VARIANT-VALUE
CALL 'c$getvariant' USING VARIANT-VALUE, PROPERTY-VALUE
call to c$getvariant produces - 'Invalid or missing parameter to "C$GETVARIANT" '
Method 2:
MODIFY CR-REPORT @OPENREPORT (REPORT-PATH)
RETURNING REPORT-OBJ
INQUIRE REPORT-OBJ @DATABASE IN DATABASE-OBJ
call 'c$setvariant' using database-name, database-name-v
call 'c$setvariant' using u-id, u-id-v
call 'c$setvariant' using passwd, passwd-v
MODIFY DATABASE-OBJ @LOGONSERVER
('crdb_ado.dll', server-name, database-name-v,
u-id-v, pASSwD-v)
Type mismatch error.



