Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

How to Dispose Report Object while using session

$
0
0

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”

 

ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load

        IfNot Page.IsPostBack Then

Session("Report") = Nothing

        EndIf

        If Session("Report") IsNothingThen

rpt = NewReportDocument

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 = NewReportDocument

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

        EndIf

    EndSub

    ProtectedSub Page_Unload(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Unload

        If rpt IsNotNothingThen

rpt.Close()

rpt.Dispose()

        EndIf

    EndSub

    ProtectedSub CrystalRreport_Unload(ByVal sender AsObject, ByVal e As System.EventArgs) Handles CrystalReport.Unload

        If rpt IsNotNothingThen

rpt.Close()

rpt.Dispose()

        EndIf

    EndSub

EndClass


Viewing all articles
Browse latest Browse all 3636


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>