Link to home
Start Free TrialLog in
Avatar of lanier3532
lanier3532

asked on

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)
Avatar of Mike McCracken
Mike McCracken

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
Avatar of lanier3532

ASKER

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...
I don't know then.

mlmcc
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.
Can you elaborate, please? Thanks.
Attached is a PDF file that describes how I use the push method.
Crystal-Reports-Tutorial.pdf
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!