Crystal Reports XI exporting blank .PDF's

Hello Experts,
i have a vb.net application which uses Crystal Reports XI to automatically create a .pdf file and then email it a list of users.

90% of the time, it works fine.  Sometimes the .pdf is empty of data.  It has the labels, boxes, etc., but no data.  Every time i run the app in debug mode, perfect.  if you trigger the report to run again, you may get data.  i can't reproduce the problem, it is sporadic.

i've tried to put timers in to delay code execution hoping that Crystal could "catch up" when querying the database (Microsoft Access database), but no measurable improvement.

here is my code:
            lblStatus.Text = "Loading rpt...2 sec"
            Application.DoEvents()
            Sleep(2000)

            rpt = New ReportDocument

            rpt.Load(gPath & "ApprovedOrder.rpt")
            rpt.Refresh()

            lblStatus.Text = "Set parameters, logon...2 sec"
            Application.DoEvents()
            Sleep(2000)

            rpt.RecordSelectionFormula = " {Orders.ProjectNumber}='" & rs.Fields("ProjectNumber").Value & "'"
            rpt.SetParameterValue("@ShippingLabel", ShippingLabel)
            rpt.SetParameterValue("@EnteredBy", EnteredBy)
            logOnToServer(rpt)

            lblStatus.Text = "Exporting...5 sec"
            Application.DoEvents()
            Sleep(5000)

            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, gPath & "Reports\" & ProjectNumber & ".pdf")

            lblStatus.Text = "Closing...2 sec"
            Application.DoEvents()
            Sleep(5000)

            'rpt.PrintToPrinter(1, False, 1, 1)
            rpt.Close()
            rpt.Dispose()
            rpt = Nothing

            lblStatus.Text = "Emailing...2 sec"
            Application.DoEvents()
            Sleep(2000)
lanier3532Asked:
Who is Participating?
 
Bob LearnedCommented:
Example push code:


Dim ds As DataSet = Me.ExecuteStoredProcedure(report, key)
 report.Document.SetDataSource(ds)
 Me.ReportViewer.ReportSource = report.Document

Open in new window

0
 
mlmccCommented:
Rather than exporting to disk as a pdf then emailing the pdf file, how about using Crystal to export to email with an attached pdf file.

mlmcc
0
 
lanier3532Author Commented:
that won't work.  It is running on a computer with no email client.  My software is using a 3rd party control to send this email and others...
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
mlmccCommented:
I don't know then.

mlmcc
0
 
Bob LearnedCommented:
I believe that this is another example of a problem with the "pull" method that Crystal uses.  I am finding all kinds of questions that revolve around the problems that Crystal has with pulling data from the source.  I like to control how the data is retrieved, and then "push" it to the report.  Then, I don't have to deal with login problems, and parameter problems, et. al.
0
 
lanier3532Author Commented:
Can you elaborate, please? Thanks.
0
 
Bob LearnedCommented:
Attached is a PDF file that describes how I use the push method.
Crystal-Reports-Tutorial.pdf
0
 
lanier3532Author Commented:
i've implemented the solution suggested, but have limited testing.  So far, however, things are looking good.  We'll see how it works over the next couple of weeks.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.