cancel
Showing results for 
Search instead for 
Did you mean: 

How to Dispose Report Object while using session

Former Member
0 Kudos
319

Dear SAP TEAM ,

Please help me to solve  this queries , I am struggling with below points from last  one week . searched lot of forums and blog but I didn’t get a answer ,

And My Query is 

I am using VS 2010 and inbuilt  sap crystal report  version 13 with backend oracle .

Crystal report is loading for each and every action and hitting the database every time ,  while going to accounts reports  we have 15 – 20 page of data’s

When user navigate from 1st page to 2nd page , report against hit the DB .

To avoid this problem , I have handled session in aspx page. So  1st page alone will load and after every action data’s will pull from session , its working fine .

BUT when I start to use session I can’t able to DISPOSE or CLOSE object from TEMP file . I have pasted my code and also attached sample file . please check and update .

When I am navigate to 2 nd page I am getting error “OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT”

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

Session("Report") = Nothing

        End If

        If Session("Report") Is Nothing Then

rpt = New ReportDocument

rpt.Load(Server.MapPath("CrystalReport1.rpt"))

Session.Add("Report", rpt)

rpt.SetParameterValue("Name", "SAP CRYSTAL REPORTS")

CrystalReport.HasToggleParameterPanelButton = False

CrystalReport.ToolPanelView = ToolPanelViewType.None

CrystalReport.ReportSource = CType(Session("Report"), ReportDocument)

        Else

rpt = New ReportDocument

CrystalReport.ReportSource = CType(Session("Report"), ReportDocument)

        End If

    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload

        If rpt IsNot Nothing Then

rpt.Close()

rpt.Dispose()

        End If

    End Sub

    Protected Sub CrystalRreport_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReport.Unload

        If rpt IsNot Nothing Then

rpt.Close()

rpt.Dispose()

        End If

    End Sub

End Class

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You don't have to dispose of session objects. They will expire on their own. However if you have sensitive information in the session object and want to clear it out then you can use Session.Abandon(). For more information on sessions see the following:


http://msdn.microsoft.com/en-us/library/ms178581.aspx

http://www.w3schools.com/asp/asp_sessions.asp

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Dear Ludek ,

Thanks for your quick reply , In our company we have more than 60 clients and they generating  Reports Frequently , we have more than 150 types of reports .

When temp files reached 75 Reports , it not allowed request to generate next report , In this case we cant able to wait to expire reports on their own , so we need to dispose manually in page unload event OR  crviewer unload event .

When we start to dispose rpt at session_end event , its working fine , but users close the reports before session end , then rpt will not dispose and store in temp file .if it reach 75 rpt in temp folder then user cant able to generate report. Please help me to solve this query .

Former Member
0 Kudos

See my reply here:

http://scn.sap.com/thread/3215478

and close either this thread or the one above. You'll have to do a bit of research on how sessions behave and how to manage session in general. E.g.; this is not a CR specific query and in the other thread I gave you several options I am aware of. If those do not help, see if Microsoft can help - as a general session handling question.

- Ludek

Former Member
0 Kudos

Dear Ludek ,

Really thanks for your answer .

I will  Try to get solution from  which you mentioned above  , I think you will be aware of Maximum Print job limit in crystal report . What will happen if i change PrintJobLimit Default value 75 as -1 in Regedit  .

it will allow me to generate reports even temp file stored more than 75 ?

Former Member
0 Kudos

You can certainly increase the PrintJob Limit,  but do not use -1. I wrote an article where using -1 is suggested, but later on I found out that -1 only works for special OEM builds of the Crystal Reports Server. However, there is nothing stopping you from using any other value. Say 500. Obviously, some side effects should be anticipated. By upping the number, you are essentially offloading the work on to the hardware and even IIS with web apps. E.g.; there will be a number where you will get nonsensical errors; Load report failed, DB Logons, etc. Your server may become unresponsive, etc., etc. Only testing your system, with your application will tell you the best number to use. The article I wrote:

Crystal Reports Maximum Report Processing Jobs Limit

Also see:

KB - 1496619 - Event Viewer warning; A Crystal Reports job was delayed 2 second waiting for a free licens...

- Ludek

Former Member
0 Kudos

Hi ludek ,

In your article page no 4 , you mention that (However, you still need to close and dispose of the report object eventually. This should be done on either close of the viewer browser window, or if the user navigates to another page.)

Could u please send me some sample code to dispose report object of the viewer browser window .

Former Member
0 Kudos

i too would like to see a sample that highlights how to dispose of the report object at the proper point in time when the viewer for closes

Former Member
0 Kudos

anyone looking here can find additional info and a sample in the thread

http://scn.sap.com/thread/3440682

Answers (0)