|
-
Dec 4th, 2003, 08:58 AM
#1
Thread Starter
Fanatic Member
[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:
crpt = New RMSCompareRpt()
For Each myTable In crpt.Database.Tables
myLogin = myTable.LogOnInfo
With myLogin.ConnectionInfo
.ServerName = "user"
.UserID = "pass"
.Password = ""
.DatabaseName = "Miscellaneous"
End With
myTable.ApplyLogOnInfo(myLogin)
Next
crpt.RecordSelectionFormula = "{Compare.EmpID} = " & Request.Cookies("EmpID").Value
CrystalReportViewer1.ReportSource = crpt
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.DataBind()
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
-
Dec 4th, 2003, 05:05 PM
#2
Addicted Member
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
-
Dec 5th, 2003, 08:13 AM
#3
Thread Starter
Fanatic Member
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!
-
Dec 5th, 2003, 08:59 PM
#4
Addicted Member
"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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|