I have a crystal report that runs against a query held in a SQL database.
This report is called through VB.
My problem is that the report runs very slow when called through the code.
1: i run the query in enterprise manager
2: i open the report in crystal reports
They all run instantly !!
But when called through the code it takes around 17 seconds to run, and then 17 seconds every time you click through each page.
My code is as follows:
Dim CRXApplication As New CRAXDRT.Application
Dim CRXReport As CRAXDRT.Report
Dim CRXDatabase As CRAXDRT.Database
Dim CrDatabaseTable As CRAXDRT.DatabaseTable
Set CRXReport = CRXApplication.OpenReport(APPConst.DatabasePath & stReport & ".rpt")
For Each CrDatabaseTable In CRXReport.Database.Tables
CrDatabaseTable.SetLogOnInfo APPConst.Server, APPConst.Database, APPConst.User, APPConst.DatabasePassword
Set CRXDatabase = CRXReport.Database
SQL$ = "Select * From " & stTable
SQLRecs.Open SQL$, cn, adOpenStatic
CRXDatabase.SetDataSource SQLRecs, 3, 1
Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crpParamDef As CRAXDRT.ParameterFieldDefinition
CRXReport.EnableParameterPrompting = False
Set crpParamDefs = CRXReport.ParameterFields
For Each crpParamDef In crpParamDefs
Select Case .ParameterFieldName
crViewer.Height = 9400
crViewer.Width = 14900
crViewer.Top = 50
crViewer.Left = 50
crViewer.EnableGroupTree = False
crViewer.EnableRefreshButton = False
crViewer.EnableSearchControl = False
crViewer.ReportSource = CRXReport
crViewer.Visible = True
The report i am refering to does not have any parameters to pass down, so it does not use the parameters loop.
Any advice would be appriciated on how to open a crystal report correctly based on an sql database.