Avatar of leskelly
leskelly
Flag for United States of America

asked on 

Crystal Report exported as PDF not found

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 :
File.Create("C:\WebApps\ClientTrack\Reports\TestFile.txt")

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
            Try
                'deletes all files in the folder due to *.*
                Kill("C:\WebApps\ClientTrack\Reports\*.*")
            Catch ex As System.IO.FileNotFoundException
                'If no files exist in the folder just keep going.
            End Try
            File.Create("C:\WebApps\ClientTrack\Reports\" & TodayFile)
        End If
        '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
        Try
            With crpt
                .ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
                .ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
                .ExportOptions.DestinationOptions = dfdo
                HttpContext.Current.Response.Write(.ExportOptions.DestinationOptions.DiskFileName & "<br/>")
                .Export()
                .Close()
                .Dispose()
            End With
            GC.Collect()
            GC.WaitForPendingFinalizers()
            MakePDFfile = FileName
        Catch ex As Exception
            Dim errors As String = ex.StackTrace

            Try
                If CType(crpt, ClientTrack.FinancialTransactions).ResourceName() = "FinancialTransactions.rpt" Then
                    Me.Context.Items("Financial Transactions Error") = True
                Else
                    ErrorHandler(ex)
                End If
            Catch exp As Exception
                ErrorHandler(ex)
            End Try
        End Try
    End Function

Any suggestions would be greatly appreciated.
ASP.NETCrystal Reports.NET Programming

Avatar of undefined
Last Comment
leskelly

8/22/2022 - Mon