properly close crystal report object?

D

David Lozzi

Howdy,

in a .net 2.0 application using crystal reports for visual studio 2005, my
users get the following error

System.Exception: Load report failed. --->
System.Runtime.InteropServices.COMException (0x80041016): The maximum report
processing jobs limit configured by your system administrator has been
reached. at
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
--- End of inner exception stack trace --- at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String
filename, OpenReportMethod openMethod, Int16 parentJob) at
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
at servicepartnerdispatch.Page_Load(Object sender, EventArgs e)

I've updated the registry to boost up the PrintJobLimit
(HKLM\SOFTWARE\CRYSTAL DECISIONS\10.2\Report Application Server\Server) to
175 and that works better. This application is currently in development, so
only a handful of users are accessing this and running even fewer reports.
All reports are being generated into PDF on the fly. I'm guessing I'm not
closing the object correctly? What am I missing? Shouldn't the engine release
the job once it's completed? Below is my code for a report

Dim crReport As New ReportDocument
Dim path As String =
Server.MapPath("rptServicePartnerDispatch.rpt")
crReport.Load(path)
Dim woid As Integer = Request("WOID")
Dim comp As String = Request("COMP")
Dim job As String = Request("JOB")

Dim ds As New DataSet
Dim adap As New SqlDataAdapter("cp_FrmServicePartnerDispatch",
conn)

With adap
.SelectCommand.CommandType = CommandType.StoredProcedure
.SelectCommand.Parameters.Add(New SqlParameter("@WOID", woid))
End With

conn.Open()
adap.Fill(ds, "cp_FrmServicePartnerDispatch")

crReport.SetDataSource(ds)

Dim strStream As New
System.IO.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"

Response.BinaryWrite(strStream.ReadBytes(strStream.BaseStream.Length))

Response.Flush()
Response.Close()

conn.Close()

Thanks!
 
G

George Ter-Saakov

crReport (ReportDocument) object has a Dispose method.....

You must call Dispose method when you done with object....
Not only Crystal, but FileStream, Database Connection....Any object that
supports IDisposable interface

George.


David Lozzi said:
Howdy,

in a .net 2.0 application using crystal reports for visual studio 2005, my
users get the following error

System.Exception: Load report failed. --->
System.Runtime.InteropServices.COMException (0x80041016): The maximum
report
processing jobs limit configured by your system administrator has been
reached. at
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
--- End of inner exception stack trace --- at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String
filename, OpenReportMethod openMethod, Int16 parentJob) at
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String
filename)
at servicepartnerdispatch.Page_Load(Object sender, EventArgs e)

I've updated the registry to boost up the PrintJobLimit
(HKLM\SOFTWARE\CRYSTAL DECISIONS\10.2\Report Application Server\Server) to
175 and that works better. This application is currently in development,
so
only a handful of users are accessing this and running even fewer reports.
All reports are being generated into PDF on the fly. I'm guessing I'm not
closing the object correctly? What am I missing? Shouldn't the engine
release
the job once it's completed? Below is my code for a report

Dim crReport As New ReportDocument
Dim path As String =
Server.MapPath("rptServicePartnerDispatch.rpt")
crReport.Load(path)
Dim woid As Integer = Request("WOID")
Dim comp As String = Request("COMP")
Dim job As String = Request("JOB")

Dim ds As New DataSet
Dim adap As New SqlDataAdapter("cp_FrmServicePartnerDispatch",
conn)

With adap
.SelectCommand.CommandType = CommandType.StoredProcedure
.SelectCommand.Parameters.Add(New SqlParameter("@WOID",
woid))
End With

conn.Open()
adap.Fill(ds, "cp_FrmServicePartnerDispatch")

crReport.SetDataSource(ds)

Dim strStream As New
System.IO.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"

Response.BinaryWrite(strStream.ReadBytes(strStream.BaseStream.Length))

Response.Flush()
Response.Close()

conn.Close()

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top