Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: A Crystal Reports job failed because a free...... Post Reply Post New Topic
Author Message
yasinirshad
Newbie
Newbie
Avatar

Joined: 24 Sep 2007
Location: Saudi Arabia
Online Status: Offline
Posts: 39
Quote yasinirshad Replybullet Topic: A Crystal Reports job failed because a free......
    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)

"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.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.014 seconds.