Results 1 to 4 of 4

Thread: [Resolved] Trying to save Crystal report to file cause error

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    [Resolved] Trying to save Crystal report to file cause error

    Hi, I'm trying to save my open Crystal report to a file so I can then load the file and export it to PDF. Here is my code to save the file.
    VB Code:
    1. crpt = New RMSCompareRpt()
    2.         For Each myTable In crpt.Database.Tables
    3.             myLogin = myTable.LogOnInfo
    4.             With myLogin.ConnectionInfo
    5.                 .ServerName = "user"
    6.                 .UserID = "pass"
    7.                 .Password = ""
    8.                 .DatabaseName = "Miscellaneous"
    9.             End With
    10.             myTable.ApplyLogOnInfo(myLogin)
    11.         Next
    12.         crpt.RecordSelectionFormula = "{Compare.EmpID} = " & Request.Cookies("EmpID").Value
    13.  
    14.         CrystalReportViewer1.ReportSource = crpt
    15.         CrystalReportViewer1.RefreshReport()
    16.         CrystalReportViewer1.DataBind()
    17.  
    18.         crpt.SaveAs("C:\Test.rpt", ReportFileFormat.VSNetFileFormat)
    This causes the following error.

    Invalid file name.
    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.LoadSaveReportException: Invalid file name.

    Source Error:


    Line 59: CrystalReportViewer1.DataBind()
    Line 60:
    Line 61: crpt.SaveAs("C:\Test.rpt", ReportFileFormat.VSNetFileFormat)
    Line 62:
    Line 63:

    Anyone have a workaround for this?

    Thanks
    Last edited by indydavid32; Dec 10th, 2003 at 08:42 AM.
    David Wilhelm

  2. #2
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    If you are just trying to write a report to the browser in PDF format, it is better not to actually create a file. Bad Idea giving a user permission to write to disk. Here is a good samp of writing to memory and sending the file to the browser.
    CR to PDF

    If you must create a file post back and I'll find that code for you. I haven't used it for a while so I'd have to look for it.
    "And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
    Frank Zappa

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    MasterBlaster, thanks for the reply.

    I would like that code if you don't mind looking for it. This page will only be ran by a few people. It's not for the general public so it's not an issue writing a few reports to the server each day.

    Thanks again!

    David Wilhelm

  4. #4
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    "And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
    Frank Zappa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width