Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Load report failed. Post Reply Post New Topic
Author Message
justdotnetachar
Newbie
Newbie


Joined: 18 Aug 2008
Location: India
Online Status: Offline
Posts: 7
Quote justdotnetachar Replybullet Topic: Load report failed.
    Posted: 28 Oct 2008 at 4:18am
I am getting in Load report failed in crystal reports after 75 times.I have added the code  
        crReportDocument.Close()
        crReportDocument.Dispose()
in Page unload. but it is giving me error as Object reference not set to an instance of an object . Is there any ways i can rectify this error.please help me out. Thanks in advance.
vin
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Oct 2008 at 11:52am
Also call GC.Collect() to force garbage collection. Otherwise it stays in memory till IIS chooses to release it.
 
In ASP.NET pages, I always store the report object in the Session() collection so that I can reference it between page loads. Are you doing the same? If so, make sure you set it equal to null (Nothing in VB).
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
justdotnetachar
Newbie
Newbie


Joined: 18 Aug 2008
Location: India
Online Status: Offline
Posts: 7
Quote justdotnetachar Replybullet Posted: 29 Oct 2008 at 12:20am
   <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" EnableDrillDown="False" HasToggleGroupTreeButton ="False"
                    DisplayPage="true" HasCrystalLogo="False" HasRefreshButton="True"
                    HasSearchButton="False" ReuseParameterValuesOnRefresh="True"
                    AutoDataBind="True" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False"
                    EnableParameterPrompt="False" PrintMode="ActiveX"></CR:CrystalReportViewer>




Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Security.Principal
Imports System.Data
Imports System.Web
Imports ScheduleAssistant.BusinessLayer
Imports ScheduleAssistant.Common.Utils

Partial Class Reports_Report

    Inherits System.Web.UI.Page

    'Day - WeekId, StoreTypeId, Day (1 to 7) ->[uspGetDayScheduleDetailsView]
    'Week - WeekId, StoreTypeId -> [uspGetWeekDetailsView]

    Dim i As String

    
    Dim crReportDocument As ReportDocument
    Dim crConnInfo As New ConnectionInfo

    Protected Sub Page_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
       
    End Sub
    Private Sub DisposeCrystalDoc()
        If Not (crReportDocument Is Nothing) Then
            crReportDocument.Clone()
            crReportDocument.Dispose()
            'CrystalReportViewer1.Dispose()

        End If
        crReportDocument = Nothing
    End Sub

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Helper.validateRoleAuthentication("Report")
        Try
            Dim sqlConn As String = ""
            Dim dSet As DataSet = New DataSet
            Dim sqlParamsID(3) As SqlClient.SqlParameter
            Dim strReportName As String = PresentationConstant.DAYWISEREPORT
            Dim storeType As Constants.StoreType
            Dim storeNumber As String = String.Empty
            Dim regionId As String = String.Empty
            Dim reportId As Integer = 0
            Dim reportLevel As Constants.LevelType
            Dim districtId As Integer = 0
            Dim source As String = String.Empty
            Dim levelID As Integer

            Dim weekStartDate As DateTime = New DateTime()
            Dim weekEndDate As DateTime = New DateTime()
            Dim strReportPath As String
            Dim areaId As String = String.Empty
            If Not IsPostBack Then

                'dayOrWeek = Request.QueryString("DayOrWeek")
                reportLevel = Convert.ToInt32(Request.QueryString("ReportLevel"))
                If (Request.QueryString("ReportId") <> Nothing) Then
                    reportId = CInt(Request.QueryString("ReportId"))
                End If


                If (reportLevel = Constants.LevelType.Store) Then 'Store
                    levelID = Convert.ToInt32(Request.QueryString(AppConstants.STOREID))
                ElseIf (reportLevel = Constants.LevelType.District) Then 'District
                    levelID = Convert.ToInt32(Request.QueryString(AppConstants.DISTRICTID))
                ElseIf (reportLevel = Constants.LevelType.Area) Then 'Area
                    levelID = Convert.ToInt32(Request.QueryString(AppConstants.AREAID))
                ElseIf (reportLevel = Constants.LevelType.Region) Then 'Region
                    levelID = Convert.ToInt32(Request.QueryString(AppConstants.REGIONID))
                End If

                Select Case reportId
               
                    Case 7 'Offset Report
                        strReportName = PresentationConstant.OFFSETHRSSTOREREPORT
                    Case 9 'SM ASM
                        If (reportLevel = Constants.LevelType.Store) Then 'Store Level
                            strReportName = PresentationConstant.SMASMREPORT
                        ElseIf (reportLevel = Constants.LevelType.District) Then 'District Level
                            strReportName = PresentationConstant.SMASMDISTRICTREPORT
                        End If
                End Select

                strReportPath = System.AppDomain.CurrentDomain.BaseDirectory() & strReportName 'Server.MapPath(strReportName)

                source = Request.QueryString("Source")
                Select Case Request.QueryString(AppConstants.STORETYPE)
                    Case PresentationConstant.RETAIL
                        storeType = Constants.StoreType.Retail
                    Case PresentationConstant.SnR
                        storeType = Constants.StoreType.SandR
                    Case Else
                        storeType = Constants.StoreType.Both
                End Select

                If Request.QueryString(AppConstants.WEEKSTARTDATE) <> String.Empty Then
                    weekStartDate = Request.QueryString(AppConstants.WEEKSTARTDATE)
                End If

                If Request.QueryString(AppConstants.WEEKENDDATE) <> String.Empty Then
                    weekEndDate = Request.QueryString(AppConstants.WEEKENDDATE)
                End If

                'Check file exists
                If Not IO.File.Exists(strReportPath) Then
                    Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
                End If


                crReportDocument = New ReportDocument()
                'Getting the current user's window login id

                Dim currentUser As IPrincipal
                currentUser = HttpContext.Current.User
                Dim userName As String = currentUser.Identity.Name

                Dim _db_server As String = ConfigurationManager.AppSettings("Server")
                Dim _db_name As String = ConfigurationManager.AppSettings("Database")
                Dim _user_id As String = ConfigurationManager.AppSettings("UserID")
                Dim _pwd As String = ConfigurationManager.AppSettings("Password")
                Dim _iSecurity As String = ConfigurationManager.AppSettings("IntegratedSecurity")

                Dim crDatabase As Database
                Dim crTables As Tables
                Dim crTable As Table
                Dim crLogOnInfo As TableLogOnInfo


                Dim paramLevelType As New ParameterField()
                Dim paramLevelID As New ParameterField()
                Dim paramStoreType As New ParameterField()
                Dim paramLevel As New ParameterField()
                Dim paramStartDate As New ParameterField()
                Dim paramDataType As New ParameterField()
                Dim paramDistrictName As New ParameterField()
                Dim paramRegionName As New ParameterField()
                Dim paramAreaName As New ParameterField()
                Dim paramaPStartDate As New ParameterField()
                Dim paramEndDate As New ParameterField()

                Dim discretePStartDate As New ParameterDiscreteValue()
                Dim discreteLevelType As New ParameterDiscreteValue()
                Dim discreteLevelID As New ParameterDiscreteValue()
                Dim discreteStoreType As New ParameterDiscreteValue()
                Dim discreteLevel As New ParameterDiscreteValue()
                Dim discreteStartDate As New ParameterDiscreteValue()
                Dim discreteEndDate As New ParameterDiscreteValue()
                Dim discreteDataTypeStore As New ParameterDiscreteValue()
                Dim discreteDistrictName As New ParameterDiscreteValue()
                Dim discreteRegionName As New ParameterDiscreteValue()
                Dim discreteAreaName As New ParameterDiscreteValue()

                Dim rptFields As New ParameterFields()
                crReportDocument.Load(strReportPath)
                crDatabase = crReportDocument.Database
                crTables = crDatabase.Tables

                Dim oSubRpt As New ReportDocument
                Dim crSections As Sections
                Dim crSection As Section
                Dim crReportObjects As ReportObjects
                Dim crReportObject As ReportObject
                Dim crSubreportObject As SubreportObject
                Dim s As String() = {"", ""}
                Dim index As Integer = 0

                crSections = crReportDocument.ReportDefinition.Sections


                ' '' '' '' ''Set the sections collection with report sections
                crSections = crReportDocument.ReportDefinition.Sections

                For Each crSection In crSections
                    crReportObjects = crSection.ReportObjects
                    index = 0
                    For Each crReportObject In crReportObjects
                        If crReportObject.Kind = ReportObjectKind.SubreportObject Then

                            crSubreportObject = CType(crReportObject, SubreportObject)

                            oSubRpt = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
                            s.SetValue(crSubreportObject.SubreportName, index)
                            index = index + 1
                            crDatabase = oSubRpt.Database
                            crTables = crDatabase.Tables

                            For Each crTable In crTables
                                With crConnInfo
                                    .ServerName = _db_server
                                    .DatabaseName = _db_name
                                    .UserID = _user_id
                                    .Password = _pwd
                                    ' .IntegratedSecurity = _iSecurity
                                End With
                                crLogOnInfo = crTable.LogOnInfo
                                crLogOnInfo.ConnectionInfo = crConnInfo
                                crTable.ApplyLogOnInfo(crLogOnInfo)
                                If (crTable.TestConnectivity()) Then
                                    'drop fully qualified table location
                                    If (crTable.Location.IndexOf(".") > 0) Then

                                        crTable.Location = crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
                                    Else
                                        crTable.Location = crTable.Location
                                    End If
                                End If
                                crTable.LogOnInfo.ConnectionInfo.ServerName = crConnInfo.ServerName
                            Next
                        End If
                    Next
                Next

                paramLevelType.Name = AppConstants.RPTLEVELTYPE
                paramLevelID.Name = AppConstants.RPTLEVELID
                paramStoreType.Name = AppConstants.RPTSTORETYPE
                paramLevel.Name = AppConstants.RPTLEVEL

                paramLevelType.ReportParameterType = ParameterType.ReportParameter
                paramLevelID.ReportParameterType = ParameterType.ReportParameter
                paramStoreType.ReportParameterType = ParameterType.ReportParameter
                paramLevel.ReportParameterType = ParameterType.ReportParameter

                paramLevelType.ParameterValueType = ParameterValueKind.NumberParameter
                paramLevelID.ParameterValueType = ParameterValueKind.NumberParameter
                paramStoreType.ParameterValueType = ParameterValueKind.NumberParameter
                paramLevel.ParameterValueType = ParameterValueKind.StringParameter

                discreteLevelType.Value = Convert.ToInt32(reportLevel)
                discreteLevelID.Value = levelID
                discreteStoreType.Value = Convert.ToInt32(storeType)

                If (Request.QueryString(AppConstants.STORETYPE).Equals(PresentationConstant.BOTH, StringComparison.CurrentCultureIgnoreCase)) Then
                    discreteLevel.Value = "( " + PresentationConstant.RETAIL & ", " & PresentationConstant.SnR + " )"
                ElseIf (Request.QueryString(AppConstants.STORETYPE).Equals(PresentationConstant.RETAIL, StringComparison.CurrentCultureIgnoreCase)) Then
                    discreteLevel.Value = "( " + PresentationConstant.RETAIL + " )"
                Else
                    discreteLevel.Value = "( " + PresentationConstant.SnR + " )"
                End If

                paramLevelType.CurrentValues.Add(discreteLevelType)
                paramLevelID.CurrentValues.Add(discreteLevelID)
                paramStoreType.CurrentValues.Add(discreteStoreType)
                paramLevel.CurrentValues.Add(discreteLevel)

                rptFields.Add(paramLevelType)
                rptFields.Add(paramLevelID)
                rptFields.Add(paramStoreType)
                rptFields.Add(paramLevel)

                Select Case reportId
               

                    Case 7 'Offset Hrs  
                        crReportDocument.SetParameterValue(AppConstants.RPTLEVELTYPE, Convert.ToInt32(reportLevel), AppConstants.OFFSETHRSSUBREPORT)
                        crReportDocument.SetParameterValue(AppConstants.RPTLEVELID, levelID, AppConstants.OFFSETHRSSUBREPORT)
                        crReportDocument.SetParameterValue(AppConstants.RPTSTORETYPE, Convert.ToInt32(storeType), AppConstants.OFFSETHRSSUBREPORT)

                    Case 9 'SM/ASM reports
                        If (reportLevel = Constants.LevelType.District) Then

                            paramStartDate.Name = AppConstants.RPTSTARTDATE
                            paramDistrictName.Name = AppConstants.RPTDISTRICTNAME
                            paramaPStartDate.Name = AppConstants.RPTPARAMSTARTDATE

                            paramStartDate.ReportParameterType = ParameterType.ReportParameter
                            paramDistrictName.ReportParameterType = ParameterType.ReportParameter
                            paramaPStartDate.ReportParameterType = ParameterType.ReportParameter

                            paramStartDate.ParameterValueType = ParameterValueKind.DateParameter
                            paramDistrictName.ParameterValueType = ParameterValueKind.StringParameter
                            paramaPStartDate.ParameterValueType = ParameterValueKind.DateParameter

                            discreteStartDate.Value = weekStartDate
                            discreteDistrictName.Value = Request.QueryString(AppConstants.DISTRICTNAME)
                            discretePStartDate.Value = weekStartDate

                            paramStartDate.CurrentValues.Add(discreteStartDate)
                            paramDistrictName.CurrentValues.Add(discreteDistrictName)
                            paramaPStartDate.CurrentValues.Add(discretePStartDate)

                            rptFields.Add(paramStartDate)
                            rptFields.Add(paramDistrictName)
                            rptFields.Add(paramaPStartDate)

                            crReportDocument.SetParameterValue(AppConstants.RPTLEVEL, discreteLevel.Value, AppConstants.SMASMDISTRICTSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTSTARTDATE, discreteStartDate.Value, AppConstants.SMASMDISTRICTSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTLEVELTYPE, Convert.ToInt32(reportLevel), AppConstants.SMASMDISTRICTSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTLEVELID, levelID, AppConstants.SMASMDISTRICTSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTSTORETYPE, Convert.ToInt32(storeType), AppConstants.SMASMDISTRICTSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTPARAMSTARTDATE, weekStartDate, AppConstants.SMASMDISTRICTSUBREPORT)

                        ElseIf (reportLevel = Constants.LevelType.Store) Then

                            paramStartDate.Name = AppConstants.RPTSTARTDATE
                            paramaPStartDate.Name = AppConstants.RPTPARAMSTARTDATE

                            paramStartDate.ReportParameterType = ParameterType.ReportParameter
                            paramaPStartDate.ReportParameterType = ParameterType.ReportParameter

                            paramStartDate.ParameterValueType = ParameterValueKind.DateParameter
                            paramaPStartDate.ParameterValueType = ParameterValueKind.DateParameter

                            discreteStartDate.Value = weekStartDate
                            discretePStartDate.Value = weekStartDate

                            paramStartDate.CurrentValues.Add(discreteStartDate)
                            paramaPStartDate.CurrentValues.Add(discretePStartDate)

                            rptFields.Add(paramStartDate)
                            rptFields.Add(paramaPStartDate)

                            crReportDocument.SetParameterValue(AppConstants.RPTLEVEL, discreteLevel.Value, AppConstants.SMASMSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTSTARTDATE, weekStartDate, AppConstants.SMASMSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTLEVELTYPE, Convert.ToInt32(reportLevel), AppConstants.SMASMSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTLEVELID, levelID, AppConstants.SMASMSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTSTORETYPE, Convert.ToInt32(storeType), AppConstants.SMASMSUBREPORT)
                            crReportDocument.SetParameterValue(AppConstants.RPTPARAMSTARTDATE, weekStartDate, AppConstants.SMASMSUBREPORT)
                        End If
                End Select

                CrystalReportViewer1.ReportSource = crReportDocument
                CrystalReportViewer1.ParameterFieldInfo = rptFields
                CrystalReportViewer1.DataBind()
                CrystalReportViewer1.Visible = True
                Session("crpt") = crReportDocument
            Else
                CrystalReportViewer1.ReportSource = Session("crpt")

            End If

        Catch ex As Exception
            Session(AppConstants.SESSIONERROR) = ex.Message
            Throw ex
        End Try
    End Sub

 
    Private Sub Page_Unload(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Unload
        If Not (crReportDocument Is Nothing) Then
            crReportDocument.Close()
            crReportDocument.Dispose()

        End If
        crReportDocument = Nothing
   




    'End Sub

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Dim storeType As String = String.Empty
        Dim storeNumber As String = String.Empty


        If (Request.QueryString("Source").Equals(AppConstants.DISTRICT)) Then
            If (String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKSTARTDATE).ToString()) And _
                String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKENDDATE).ToString()) _
               ) Then
                Response.Redirect(PresentationConstant.ASPX_DMREPORTS)
            Else
                Response.Redirect("DistrictManagerReports.aspx?WeekStartDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKSTARTDATE)).ToShortDateString() + _
                    "&WeekEndDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKENDDATE)).ToShortDateString())
            End If
        ElseIf (Request.QueryString("Source").Equals(PresentationConstant.ARD)) Then
            If (String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKSTARTDATE).ToString()) And _
                String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKENDDATE).ToString()) _
               ) Then
                Response.Redirect(PresentationConstant.ASPX_ARDREPORTS)
            Else
                Response.Redirect("ARDReports.aspx?WeekStartDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKSTARTDATE)).ToShortDateString() + _
                                    "&WeekEndDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKENDDATE)).ToShortDateString())
            End If
        ElseIf (Request.QueryString("Source").Equals("Admin")) Then
            If (String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKSTARTDATE).ToString()) And _
                String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKENDDATE).ToString()) _
               ) Then
                Response.Redirect(PresentationConstant.ASPX_ADMINSETTINGS)
            Else
                Response.Redirect("AdminSettings.aspx?WeekStartDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKSTARTDATE)).ToShortDateString() + _
                                                "&WeekEndDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKENDDATE)).ToShortDateString())
            End If
        ElseIf (Request.QueryString("Source").Equals("RM")) Then
            If (String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKSTARTDATE).ToString()) And _
                String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKENDDATE).ToString()) _
               ) Then
                Response.Redirect(PresentationConstant.ASPX_RMREPORTS)
            Else
                Response.Redirect("RegionalManagerReports.aspx?WeekStartDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKSTARTDATE)).ToShortDateString() + _
                                    "&WeekEndDate=" + Convert.ToDateTime(Request.QueryString(AppConstants.WEEKENDDATE)).ToShortDateString())
            End If
        ElseIf (Request.QueryString("Source").Equals("Store")) Then
            storeType = Request.QueryString(AppConstants.STORETYPE)
            storeNumber = Request.QueryString(AppConstants.STOREID)
            If (String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKSTARTDATE).ToString()) And _
                String.IsNullOrEmpty(Request.QueryString(AppConstants.WEEKENDDATE).ToString()) _
               ) Then
                Response.Redirect("StoreReports.aspx?StoreType=" & storeType & "&StoreNo=" & storeNumber)
            Else
                Response.Redirect("StoreReports.aspx?StoreType=" & storeType & "&StoreNo=" & storeNumber _
                & "&WeekStartDate=" & Convert.ToDateTime(Request.QueryString(AppConstants.WEEKSTARTDATE)).ToShortDateString() & "&WeekEndDate=" & _
                Convert.ToDateTime(Request.QueryString(AppConstants.WEEKENDDATE)).ToShortDateString())
            End If
        End If
    End Sub

End Class





Yes i am using the session also. As u have mentioned i have used    crReportDocument = Nothing in page unload method
and also  i have added the  condition
If Not (crReportDocument Is Nothing) Then
            crReportDocument.Close()
            crReportDocument.Dispose()

        End If
Since if i use close and dispose method directly then i am getting "Object reference not set to an instance of an object " error so i have added above condition. now it is working fine only when there is one page if the reports leads to second page then when i click to second page on crstal report tool bar then i am getting as "Object reference not set to an instance of an object " error.   Removing close and dispose method  and just adding crReportDocument = Nothing is not working out for me.So i have  included that condition(If Not (crReportDocument Is Nothing)) then added close and dispose method.condition to handle Object reference not set to an instance of an object.So whats wrong i have done here.
 
vin
IP IP Logged
justdotnetachar
Newbie
Newbie


Joined: 18 Aug 2008
Location: India
Online Status: Offline
Posts: 7
Quote justdotnetachar Replybullet Posted: 29 Oct 2008 at 12:25am
For the above code error come only when i goto more than single page.First page is showing up correctly.Error occurs only after 75th time


Edited by justdotnetachar - 29 Oct 2008 at 12:26am
vin
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 29 Oct 2008 at 1:48am
Put your code in the Page_Init() event instead of Page_Load(). There are timing conflicts with the crystal reports viewstate data and page creation process. Putting it in Page_Init() gets rid of many errors. Try that and see if it helps.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
justdotnetachar
Newbie
Newbie


Joined: 18 Aug 2008
Location: India
Online Status: Offline
Posts: 7
Quote justdotnetachar Replybullet Posted: 29 Oct 2008 at 3:18am
I tried with page_Init but still i am getting the error in second page.It does not mattered. Even i have included gc.collect(). But still it is not working.if i remove page_unload method then still i am getting as load report failed.but if i include page_unload method then i am getting an error of "object reference error" in secod page but not in first page :(
vin
IP IP Logged
justdotnetachar
Newbie
Newbie


Joined: 18 Aug 2008
Location: India
Online Status: Offline
Posts: 7
Quote justdotnetachar Replybullet Posted: 12 Nov 2008 at 1:49am
Finally my buddy Lav jangid found the answer to my reports Now they are working fine even after 75 times without any problems. i just commented out
 'crReportDocument = New ReportDocument() in the above code.Added
Dim crReportDocument As ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument() this code  outside all methods.It works fine even after 75 times.There is no need of dispose method at this time.Dispose method will work fine when there is only one page.Means when there is no crystal tool bar then export option if page exceeds more than 1 then dispose method will cretae a problem.So it is not recommended.
vin
IP IP Logged
jrmnet
Newbie
Newbie


Joined: 02 Dec 2008
Online Status: Offline
Posts: 1
Quote jrmnet Replybullet Posted: 02 Dec 2008 at 9:53am
justdotnetachar,

We have the same problem as you, with a constant failure after a certain number of reports.

We tried to do the same changes that you made, but it we still get failures.

Are you sure those are the only changes that were made?

I saw that you listed what you changed, but could you post the code for the new page?


IP IP Logged
vuquangbg
Newbie
Newbie
Avatar

Joined: 16 Dec 2008
Location: Vietnam
Online Status: Offline
Posts: 2
Quote vuquangbg Replybullet Posted: 16 Dec 2008 at 6:56pm
Dim table As CrystalDecisions.CrystalReports.Engine.Table
                    Dim tableInfo As CrystalDecisions.Shared.TableLogOnInfo
                    reportDocument1.OpenSubreport("Crt_Baocao1sub")
                    For Each table In reportDocument1.Subreports("Crt_Baocao1sub").Database.Tables
                        tableInfo = table.LogOnInfo
                        With tableInfo.ConnectionInfo
                            .ServerName = Local_SVR
                            .DatabaseName = Local_DB
                            .UserID = Local_UID
                            .Password = Local_PWD
                        End With
                        table.ApplyLogOnInfo(tableInfo)
                        table.Location = Local_DB & ".dbo." & table.Name
                    Next
                    reportDocument1.Subreports("Crt_Baocao1sub").SetParameterValue("@Flatsub", 0)
                    reportDocument1.Subreports("Crt_Baocao1sub").SetParameterValue("@Province_ID", "35")

---> error : System.NotSupportedException - Not supported within subreports.

thanks for Reply
IP IP Logged
zechs
Newbie
Newbie


Joined: 15 Jan 2009
Online Status: Offline
Posts: 1
Quote zechs Replybullet Posted: 15 Jan 2009 at 9:52pm
Originally posted by justdotnetachar

Finally my buddy Lav jangid found the answer to my reports Now they are working fine even after 75 times without any problems. i just commented out
 'crReportDocument = New ReportDocument() in the above code.Added
Dim crReportDocument As ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument() this code  outside all methods.It works fine even after 75 times.There is no need of dispose method at this time.Dispose method will work fine when there is only one page.Means when there is no crystal tool bar then export option if page exceeds more than 1 then dispose method will cretae a problem.So it is not recommended.


I tried this in my program but it seems like doesn't effect.
Maybe somethings left by you to explain or?
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.039 seconds.