We help IT Professionals succeed at work.
Get Started

Crystal Report exported as PDF not found

664 Views
Last Modified: 2013-12-08
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.
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE