Solved

Crystal Report exported as PDF not found

Posted on 2013-12-02
3
557 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.
0
Comment
Question by:leskelly
  • 2
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Did you change the report to use the new database?
DO they run in the designer?

mlmcc
0
 

Accepted Solution

by:
leskelly earned 0 total points
Comment Utility
I found a web page with the solution to my problem.  

http://msdn.microsoft.com/en-us/library/ff647402.aspx#paght000015_sqlserver

If anyone else is having this problem go to the link above.  At the top of the page is a Contents area.  Click on SQL Server and it will take you to the relevant section.
0
 

Author Closing Comment

by:leskelly
Comment Utility
I found my own solution.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now