Why does Crystal take so long to set datasource only the first time
-
Hi all, I'm trying to track down why my report takes so long to load the first time but subsequent loads are quite quick. I'm setting the datasource of the report to a dataset, but that's done every time. However, in stepping through the code, I've found that the first time I run this segment of code, it takes a few seconds for the data source to get set. But on subsequent runs it takes no longer than any other command. Any ideas? I've posted the relevant part of the code below.
If ds.Tables(0).Rows.Count > 0 Then
AddImageColumn(ds.Tables(0), "ClientPic")
Dim myFilename As String
myFilename = myG.AppLocation & "\" & myDB.DoExecScalarQuery("select picture from personal")
If File.Exists(myG.AppLocation & "\ClientDocs\" & myG.Patient & "_clientimage.jpg") Then
If File.Exists(myFilename) Then
LoadImage(ds.Tables(0).Rows(0), "ClientPic", myFilename)
End If
ds.WriteXml(applocation & "\personal.xml")
ds.WriteXmlSchema(myG.AppLocation & "\personal.xsd")
'Dim rptPersonal As New crptPersonalInfo ' now declared in main
rptPersonal.SetDataSource(ds) ' THIS IS THE LINE THAT'S SLOW THE FIRST TIME
' Dim rptPersonalViewer As New frmReportViewer ' now declared in main
rptPersonalViewer.cr.ReportSource = rptPersonal
rptPersonalViewer.ShowDialog()
Else
MsgBox("Please check your personal information. It appears some of it may be missing.",
MsgBoxStyle.OkOnly, "No Data For Report")
End IfCatch ex As Exception
Dim myE As New EventLogging.EventLogging
myE.StoreEvent("frmRptParams.RunReport", "Error running report", ex.Message & vbCrLf & vbCrLf & "SQL was: " & strPersonalInfo)
myE = Nothing
MsgBox("There was a problem gathering data for the Personal Info report. If the problem persists please contact customer service.", MsgBoxStyle.Exclamation, "Report Not Run")
Finally
da = Nothing
ds = Nothing
End TryDenise "Hypermommy" Duggan