Skip to Content
0
Former Member
Sep 13, 2007 at 05:46 PM

All reports stay in c:\temp, how to remove them?

45 Views

Post Author: bart@dataconsult.com

CA Forum: .NET

Dear experts,

All the opened reports stay in the tempfile on our server. when there are 75 files opened I get the error "Load report failed".

When I search on the net everyone suggests to use ReportDocument.Close() and ReportDocument.Dispose() on the event Page_Unload().

This doesn't work at all, all the files stay in my temp file if I close my page, close my brower or navigate to another page.

Before the report is printed, the file is 3 times loaded which uses a lot of memory from our webserver.

The file is loaded a first time when it's displayed on the screen. A second time when I click the print icon and a third time when the pdf file opens in my browser.

So in fact, I can only open and print 25 reports and then I get the error u201CLoad report failedu201D. The only thing I can do then is restart the website in IIS.

What is the good solution to prevent those files in c:\Temp?

This is my code to load a report: Sub LoadReport() Dim strReportUrl as string = "../cr/appl_p04.rpt" Dim oRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument If oRpt.IsLoaded Then oRpt.Close() End If Dim intStudentNr As Integer = ddlStudent.SelectedItem.Value

oRpt.Load(MapPath(strReportUrl)) oRpt.SetDatabaseLogon("myusername", "mypassword", "myserver", "mydatabase") oRpt.SetParameterValue("StudentNr", intStudentNr) CrystalReportViewer1.ReportSource = oRpt CrystalReportViewer1.Visible = True End Sub

In Page_Unload i have: Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Dim oRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt.Close() oRpt.Dispose() GC.Collect() End Sub

Kind regards,

Bart