Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

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)
0
lanier3532
Asked:
lanier3532
  • 3
  • 3
  • 2
1 Solution
 
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
 
mlmccCommented:
I don't know then.

mlmcc
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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
 
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
 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now