Avatar of AnnaJames77
AnnaJames77
 asked on

How to close crystal report object? PLS HELP

Public Sub ShowReport(ByVal OrderNo)
        Try
            Dim theReport As New ReportDocument
            theReport.FileName = "C:\Results.rpt"
            theReport.SetParameterValue("@orderno", OrderNo)
            CrystalReportViewer1.ReportSource = theReport
            CrystalReportViewer1.Visible = True
        Catch ex As Exception
            MsgBox("An Error Occurred: " & ex.ToString())      
        End Try

I call the above code from another form as Rep.show(parameters) in a loop;
ie
for loop
Rep.show(parameters)
end for

I want to know how should i close and dispose the report object ie, theReport.
As i get an error as below
"The maximum report processing jobs limit configured by your
system administrator has been reached.How I can Solve this
problem when i using crystal report to load from my
application."
in google its suggested to close the report object. But when i give the thereport.close and thereport.dispose it gives an error  like "Pure Virtual Function Call"
Crystal ReportsASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
_alias99

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Vikram Singh Saini

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Vikram Singh Saini

Sorry! Didn't read your last paragraph. For that problem you can click http://geekswithblogs.net/technetbytes/archive/2007/07/17/114008.aspx
Nasir Razzaq

Are you doing something else in the loop as well? If not, showing multiple reports in same viewer within a loop does not make sense. Are you printing the reports? If so then use the PrintToPrinter method directly without showing the report

http://devlibrary.businessobjects.com/businessobjectsxi/en/en/crystalreports_dotnet_sdk/crystalreports_net_doc/doc/crsdk_net_doc/html/crlrfreportdocumentclassprinttoprintermethodtopic.htm
AnnaJames77

ASKER
yes code cruiser i am not using the crystal report. i do direct printing in the loop. just for checking i use the crystal report viewer. even if i give directly i get the above same error if there are more than 1 report to print in the loop. i need to know how should i close /dispose the report object after each print
Your help has saved me hundreds of hours of internet surfing.
fblack61
Nasir Razzaq

Try setting the reportobject to Nothing. Then every so often, call the GC.Collect()

Example:

Dim Temp As Integer
For i as integer ...
   'ShowReport
   Temp += 1
   ReportDoc = Nothing
   If Temp = 10 Then
      GC.Collect()
      Temp = 0
   End If
Next
Mike McCracken

How many reports are you trying to open?
There are limits set in Crystal to the number of open connections.  That number is affected by how the report is built as I believe subreports count as a connection.

What other code are you using since the subreport ending should close the opened report document and you haven't really done anything with it other than show it in the viewer.

mlmcc
AnnaJames77

ASKER
it doesnt have any subreports. There can be more than 30 reports to print in the loop. its chosen by the user. I want to know where should i call this dispose and close method. Is it in the calling form or on the report printing form. If i dispose it in the report printing form and selects only one value, ie the loop executes only once then there isnt any error. But if selects more than one, then i get  error : object not set to an instance of the object.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Nasir Razzaq

Show us the code from the form that is printing and the code that is calling it.
Mike McCracken

I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
AnnaJames77

ASKER
i used the
theReport.Close();
theReport.Dispose();
to solve the issue
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Mike McCracken

Asker has provided the answer.

The answer is basically the code provide by vs00saini in the first comment

https://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_27243619.html?cid=1572#a36327679 

Please change recommendation to

Accepted Answer - vs00saini  https://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_27243619.html?cid=1572#a36327679

mlmcc
CV
_alias99

All,
 
Following an 'Objection' by mlmcc (at https://www.experts-exchange.com/Q_27293076.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
 
At this point I am going to re-start the auto-close procedure.
 
Thank you,
 
_alias99
Community Support Moderator