Hi All,
Following Code is very useful for Connecting Crystal Report,
DEF VAR AxViewer_Handle AS COM-HANDLE NO-UNDO.
DEF VAR chApplication AS COM-HANDLE NO-UNDO.
DEF VAR chDocument AS COM-HANDLE NO-UNDO.
DEF VAR chDatabase AS COM-HANDLE NO-UNDO.
DEF VAR chParamDefs AS COM-HANDLE NO-UNDO.
DEF VAR ResultText AS CHAR NO-UNDO.
CREATE "CrystalRuntime.Application.11" chApplication.
chDocument = chApplication:OpenReport("Report Path like (C:\Users\prabu\Desktop\TestRpt.rpt)", 1).
chDatabase = chDocument:DATABASE.
chParamDefs = chDocument:ParameterFields.
chDocument:Database:LogOnServer(
'pdsodbc.dll',
'apsh_hisdb', /* DSN Name What ever in ODBC Connection*/
'':U
'sysprogress', /* User ID (It Should be in the User Table*/
'sysprogress'). /* Password (It Should be same in User Table)*/
/* Set the value of the 1st parameter in the report */
ResultText = chParamDefs:Item(1):SetCurrentValue(Value1). /* Crystal Report Parameter and this Value are same Data Type */
/* Set the value of the 2nd parameter in the report */
ResultText1 = chParamDefs:Item(2):SetCurrentValue(Value2).
chDocument:EnableParameterPrompting = FALSE.
chCtrlFrame:CrystalActiveXReportViewer:ReportSource = chDocument.
chCtrlFrame:CrystalActiveXReportViewer:REFRESH.
chCtrlFrame:CrystalActiveXReportViewer:ViewReport.
RELEASE OBJECT chApplication.
RELEASE OBJECT chDocument.