|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Invalid file name when printing Crystal ReportI am newbie for ASP.NET programming and I am having this error when I tried to print a crytal report from my dotnet web application. Error Message : Invalid file name. at ?.?K(String ? , EngineExceptionErrorID ? ) at ?.?F(Int16 ??, Int32 ??) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestCont ext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() at CrystalWeb.ReportPrinter.Page_Init(Object sender, EventArgs e) in c:\inetpub\wwwroot\CrystalWeb\ReportPrinter.aspx.vb:line 42 Following is my code for the printing : Dim crReportDocument As ReportDocument Dim crExportOptions As ExportOptions Dim crDiskFileDestinationOptions As DiskFileDestinationOptions Dim Fname As String crReportDocument = New ReportDocument() crReportDocument.Load("C:\Inetpub\wwwroot\CrystalWeb\CrystalReport\Report1.r pt") Fname = "C:\Inetpub\wwwroot\CrystalWeb\Download\" & Session.SessionID.ToString & ".pdf" crDiskFileDestinationOptions = New DiskFileDestinationOptions() crExportOptions = crReportDocument.ExportOptions With crExportOptions .DestinationOptions = crDiskFileDestinationOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat End With Try crReportDocument.Export() ' <-----Error Occured Here Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.WriteFile(Fname) Response.Flush() Response.Close() System.IO.File.Delete(Fname) Catch err As Exception Response.Write("<BR><BR>") Response.Write(err.Message.ToString) Response.Write("<BR><BR>") Response.Write(err.StackTrace.ToString) End Try I exhausted all method that i know of and still don't know what is wrong. anyone can help me out with this ? Any help is very much appreciated. -- Bernard Goh IT Administrator Success Electronics & Transformer Manufacturer Sdn Bhd No.5 & 7,Jalan TSB 8 Taman Industri Sg. Buloh 47000 Sg.Buloh Selangor Darul Ehsan You have told it to export to file, but have not given it a file name. I
think you will need to create a stream export it to that, then read that stream back to the browser. Show quoteHide quote "Bernard Goh" <bghs***@hotmail.com> wrote in message news:OTWG594XGHA.4424@TK2MSFTNGP05.phx.gbl... > Hi All, > > I am newbie for ASP.NET programming and I am having this error when I > tried > to print a crytal report from my dotnet web application. > > Error Message : > > Invalid file name. > > at ?.?K(String ? , EngineExceptionErrorID ? ) at ?.?F(Int16 ??, Int32 ??) > at > CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestCont > ext reqContext) at > CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() at > CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() at > CrystalWeb.ReportPrinter.Page_Init(Object sender, EventArgs e) in > c:\inetpub\wwwroot\CrystalWeb\ReportPrinter.aspx.vb:line 42 > > Following is my code for the printing : > > Dim crReportDocument As ReportDocument > Dim crExportOptions As ExportOptions > Dim crDiskFileDestinationOptions As DiskFileDestinationOptions > Dim Fname As String > > crReportDocument = New ReportDocument() > > > crReportDocument.Load("C:\Inetpub\wwwroot\CrystalWeb\CrystalReport\Report1.r > pt") > > Fname = "C:\Inetpub\wwwroot\CrystalWeb\Download\" & > Session.SessionID.ToString & ".pdf" > > crDiskFileDestinationOptions = New DiskFileDestinationOptions() > > crExportOptions = crReportDocument.ExportOptions > With crExportOptions > .DestinationOptions = crDiskFileDestinationOptions > .ExportDestinationType = ExportDestinationType.DiskFile > .ExportFormatType = ExportFormatType.PortableDocFormat > End With > > Try > crReportDocument.Export() ' <-----Error Occured Here > > Response.ClearContent() > Response.ClearHeaders() > Response.ContentType = "application/pdf" > Response.WriteFile(Fname) > Response.Flush() > Response.Close() > > System.IO.File.Delete(Fname) > Catch err As Exception > Response.Write("<BR><BR>") > Response.Write(err.Message.ToString) > Response.Write("<BR><BR>") > Response.Write(err.StackTrace.ToString) > End Try > > I exhausted all method that i know of and still don't know what is wrong. > anyone can help me out with this ? > > Any help is very much appreciated. > > -- > Bernard Goh > IT Administrator > Success Electronics & Transformer Manufacturer Sdn Bhd > No.5 & 7,Jalan TSB 8 > Taman Industri Sg. Buloh > 47000 Sg.Buloh > Selangor Darul Ehsan > >
Other interesting topics
New to ASP
Is this AJAX? (Sort of "Off Topic") Help removing a reference in a web site Convert New Lines to BRs Translating ID bound to label in detailsView to NAME basing on different datasource. Anyone care to help explain forms authentication in 2.0? how do yoiu ASP.NET from changing the id attribute???? ASP.NET: Can't Kill EXCEL.exe with Office PIA Update Query in formview Parsing Request.Headers.ToString() |
|||||||||||||||||||||||