Crystal Report exported as PDF not found
Posted on 2013-12-02
I have an ASP.NET application which stores data in SQL Server 2000. I'm in the process of migrating the data to SQL Server 2008 R2. I created a test version of the application which is exactly the same as the production version except it uses SQL Server 2008 R2 which contains a copy of the data. Everything works fine except the reports no longer open. The reports were developed with Crystal Reports XI. The reports open in the test version on my development machine but not from the test site on the production server.
I believe the problem is because the application in on one server and SQL Server 2008 R2 is on another. If I point one of the reports back to SQL Server 2000 it will then open.
Both the production and the test application should save the exported PDF file to the same folder. The test app will create a file in that folder using :
The app has a function which excepts a Crystal Report as a parameter and should export a PDF file. Below is my code.
Public Function MakePDFfile(ByVal crpt As Object) As String
Dim TodayFile As String
Dim dfdo As New CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim FileName As String
'Check to see if the C:\WebReports folder has been purged today.
'If it hasn't delete everything in it and created a file named after
'today's date to indicate that it has been purged today.
TodayFile = Month(Now) & Day(Now) & Year(Now)
'If the file doesn't exist, kill everything and re-create it.
If Not File.Exists("C:\WebApps\ClientTrack\Reports\" & TodayFile) Then
'deletes all files in the folder due to *.*
Catch ex As System.IO.FileNotFoundException
'If no files exist in the folder just keep going.
File.Create("C:\WebApps\ClientTrack\Reports\" & TodayFile)
'Create a PDF file from the Crystal Report that was passed to this function.
FileName = DateAndTime.Timer & Session("UserName") & ".pdf"
dfdo.DiskFileName = "C:\WebApps\ClientTrack\Reports\" & FileName
.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
.ExportOptions.DestinationOptions = dfdo
HttpContext.Current.Response.Write(.ExportOptions.DestinationOptions.DiskFileName & "<br/>")
MakePDFfile = FileName
Catch ex As Exception
Dim errors As String = ex.StackTrace
If CType(crpt, ClientTrack.FinancialTransactions).ResourceName() = "FinancialTransactions.rpt" Then
Me.Context.Items("Financial Transactions Error") = True
Catch exp As Exception
Any suggestions would be greatly appreciated.