Home All Groups Group Topic Archive Search About

Invalid file name when printing Crystal Report

Author
14 Apr 2006 6:49 AM
Bernard Goh
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

Author
14 Apr 2006 11:47 AM
OHM ( One Handed Man )
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.

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net



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
>
>

Bookmark and Share