Wrox Programmer Forums
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2004, 09:44 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export to .pdf

I am trying to export reports to pdf through ASP.net I keep on getting the same error when the line to execute the export is ran. I cannot figure it out for the life of me... Please help

HERE IS MY CODE:

        '****************************

        Dim ShipReportDocument As ReportDocument
        Dim ExportOptions As ExportOptions
        Dim DiskFileDestOptions As DiskFileDestinationOptions
        Dim Fname As String

        ShipReportDocument = New ReportDocument
        ShipReportDocument.Load("C:\Inetpub\wwwroot\Report Generator\" & ShipClass & "_SHIP_RPT.rpt")
        ShipReportDocument.Refresh()

        Fname = "C:\Inetpub\wwwroot\ReportGenerator\" & Session.SessionID.ToString & ".pdf"
        DiskFileDestOptions = New DiskFileDestinationOptions
        DiskFileDestOptions.DiskFileName = Fname

        ExportOptions = ShipReportDocument.ExportOptions
        With ExportOptions
            .DestinationOptions = DiskFileDestOptions
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With

        ShipReportDocument.SetParameterValue("Ship_Name", ShipName)
        ShipReportDocument.SetDatabaseLogon(Session("UserI D"), Session("Password"))
        ShipReportDocument.Export()

        With Response
            .ClearContent()
            .ClearHeaders()
            .ContentType = "application/pdf"
            .WriteFile(Fname)
            .Flush()
            .Close()
        End With

        System.IO.File.Delete(Fname)

        '***************************

HERE IS THE ERROR:

Server Error in '/ReportGenerator' Application.
--------------------------------------------------------------------------------

Error in File C:\Inetpub\wwwroot\ReportGenerator\LHA1_SHIP_RPT.r pt: Access to report file denied. Another program may be using it.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveRep ortException: Error in File C:\Inetpub\wwwroot\ReportGenerator\LHA1_SHIP_RPT.r pt: Access to report file denied. Another program may be using it.

Source Error:


Line 251: ShipReportDocument.SetParameterValue("Ship_Name", ShipName)
Line 252: ShipReportDocument.SetDatabaseLogon(Session("UserI D"), Session("Password"))
Line 253: ShipReportDocument.Export()
Line 254:
Line 255: With Response
 
Old July 21st, 2004, 06:26 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Don't worry, I figured it out.... so this post can be closed.... for those that are interested in what solved the problem here is the solution:


The folder containing the web app needs to be granted permissions for ASP.NET. In order to do this go to the folder that contains your web app and right click on it and go to properties. Click on the security tab and click add. Then click locations and select the location that you want and click okay. In the text box labeled "Enter the object names to select" type in "ASPNET" and click okay. Then grant full permissions to this new entry. Hope it helps anyone with the same problem I had.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal export to pdf rebeccab Crystal Reports 6 August 25th, 2008 02:38 AM
export to pdf nilsan ASP.NET 1.0 and 1.1 Professional 0 February 21st, 2007 06:24 AM
Export Report into PDF format raksha Crystal Reports 0 May 11th, 2005 09:32 AM
Fail To Export To PDF muhammadhammad78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 March 9th, 2005 01:04 AM
Export in PDF Format MER78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 October 9th, 2004 11:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.