[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