String ls_file_report_path, ls_RecordSelectionFormula, ls_path_reports, ls_Report
long gi_return
OLEObject g_ole_crx_application
OLEObject g_ole_crx_report
OLEObject g_ole_crx_connection_info
OLEObject g_ole_crx_export_options
ls_path_reports = "c:\Reports\"
ls_Report = "xxx.rpt"
ls_file_report_path = ls_path_reports + ls_Report
IF not FileExists(ls_file_report_path) THEN
messagebox("Error", "File " + ls_file_report_path + " not exists")
return
end if
g_ole_crx_application = create OLEObject
gi_return = g_ole_crx_application.ConnectToNewObject('CrystalR untime.Application.10')
if gi_return < 0 then
MessageBox("Error", "Error CrystalRuntime.Application.10")
return
end if
g_ole_crx_application = g_ole_crx_application.OpenReport(ls_file_report_pa th, 1)
// Connect Database
g_ole_crx_application.Database.Tables(1).SetLogOnI nfo( "servername", "nome_database", "nome_utente", "password")
// Parameters (optional)
g_ole_crx_application.ParameterFields.GetItemByNam e("nome_parametro").AddCurrentValue("valore_parame tro")
// Record Formula (optional)
ls_RecordSelectionFormula = righttrim(lefttrim(g_ole_crx_application.RecordSel ectionFormula))
if isnull(ls_RecordSelectionFormula) or ls_RecordSelectionFormula='' then
ls_RecordSelectionFormula = 'formula'
else
ls_RecordSelectionFormula = ls_RecordSelectionFormula + 'and ' + 'formula'
end if
g_ole_crx_application.RecordSelectionFormula = ls_RecordSelectionFormula
g_ole_crx_application.EnableParameterPrompting = inv_reportviewer.gb_EnableParameterPrompting
// ole_crviewer: Crystal ActiveX Report Viewer Control 10.0
ole_crviewer.object.ReportSource(g_ole_crx_applica tion)
ole_crviewer.object.EnablePrintButton = True
ole_crviewer.object.EnableExportButton = True
ole_crviewer.object.EnableZoomControl = True
ole_crviewer.object.EnableAnimationCtrl = False
ole_crviewer.object.EnablePopupMenu = True
ole_crviewer.object.EnableProgressControl = True
ole_crviewer.object.EnableDrillDown = True
ole_crviewer.object.enablegrouptree = inv_reportviewer.gb_enablegrouptree
ole_crviewer.object.ViewReport