Print Page | Close Window

A Crystal Reports job failed because a free......

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4458
Printed Date: 30 Apr 2024 at 8:26am


Topic: A Crystal Reports job failed because a free......
Posted By: yasinirshad
Subject: A Crystal Reports job failed because a free......
Date Posted: 06 Oct 2008 at 7:23am

Hi,
am getting this error : "A Crystal Reports job failed because a free license could not be obtained in the time allocated. More licenses can be purchased direct from Crystal Decisions or through the Crystal Decisions Online "..

The application was working fine all day but suddenly started throwing above error.. I think this error started when i tried to debug one particluar crystal report which was taking a lot of time to load and throwing error "Login Failed"..

I tried to google and found below (at this site : http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_21434358.html - http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_21434358.html )

"How are you closing the reports?
  Crystal has a habit of keeping the license and database connection open until explicitly closed or the app is terminated.
"
Can anyone pls tell me how to close reports?

below is my code:

Private Sub GetReportData()
        Try
            Dim crReportDocument As New ReportDocument
            Dim ConnInfo As New ConnectionInfo
            With ConnInfo
                .ServerName = gbVariables.StrReportServer
                .DatabaseName = gbVariables.strReportDBName
                .UserID = gbVariables.strUsrName
                .Password = gbVariables.strUsrPwd
            End With
            crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "TOP50CUSTOMERS.rpt")
            Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo

            'Set Month Paramter
            Dim GetMonthValues As Int16
            GetMonthValues = Session("Month")
            Dim Per As New ParameterField
            Per.ParameterFieldName = "@Month"
            Dim Month_Value As New ParameterDiscreteValue
            Month_Value.Value = GetMonthValues
            Per.CurrentValues.Add(Month_Value)
            ParamFields.Add(Per)

            Me.CrystalReportViewer1.ReportSource = crReportDocument            crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)            Me.CrystalReportViewer1.RefreshReport()
            CrystalReportViewer1.Visible = True
        Catch ex As Exception
            lblError.Text = ex.Message.ToString
        End Try
    End Sub

Thanks to help...


-------------
Thanks,
Yasin.



Replies:
Posted By: hilfy
Date Posted: 13 Oct 2008 at 11:45am

You need to close the report and dispose of the viewer in the Page_Unload method of your page.  I don't have VB code for this, but here's what we do in C#:


  private void Page_Unload(object sender, EventArgs e)
  {
    CloseReports(crReport);
    crystalReportViewer.Dispose();
    crystalReportViewer = null;
  }

  private void CloseReports(ReportDocument reportDocument)
  {
    Sections sections = reportDocument.ReportDefinition.Sections;
    foreach (Section section in sections)
    {
      ReportObjects reportObjects = section.ReportObjects;
      foreach (ReportObject reportObject in reportObjects)
      {
        if (reportObject.Kind == ReportObjectKind.SubreportObject)
        {
          SubreportObject subreportObject = (SubreportObject)reportObject;
          ReportDocument subReportDocument =
    subreportObject.OpenSubreport(subreportObject.SubreportName);
          subReportDocument.Close();
        }
      }
    }
    reportDocument.Close();
  }
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window