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
|