locked
Load report fails RRS feed

  • Question

  • User-48702869 posted

    Hi, I am trying to open a crystal report and it fails to load. I get the error "Load report fails" at line

    oRpt.Load(Server.MapPath(rpt))

    My codes are

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Response.Expires = 0
            Response.AddHeader("pragma", "no-cache")
            Response.AddHeader("cache-content", "private")
            Response.CacheControl = "no-cache"
    
            strServerName = AppSettings.Item("ServerName")
            strDBName = AppSettings.Item("DatabaseName")
            strUN = AppSettings.Item("UserName")
            strPWD = AppSettings.Item("Password")
            rpt = Request.QueryString("rpt")
    
            BindReport()
        End Sub

     

    Private Sub BindReport()
            Dim crPrm As Hashtable
    
            crPrm = Session("Param")
            Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
            Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim dbConn As TableLogOnInfo = New TableLogOnInfo
            Dim oRpt As ReportDocument = New ReportDocument
            Dim arrTables As Object() = New Object(0) {}
            ReDim arrTables(20)
    
            oRpt.Load(Server.MapPath(rpt)) 
            crDatabase = oRpt.Database
            crDatabase.Tables.CopyTo(arrTables, 0)
            crTable = DirectCast(arrTables(0), CrystalDecisions.CrystalReports.Engine.Table)
            dbConn = crTable.LogOnInfo
            dbConn.ConnectionInfo.ServerName = strServerName
            dbConn.ConnectionInfo.DatabaseName = strDBName
            dbConn.ConnectionInfo.UserID = strUN
            dbConn.ConnectionInfo.Password = strPWD
            crTable.ApplyLogOnInfo(dbConn)
            Select Case rpt
                Case "detailOfPOByCompany2.rpt", "detailOfPRByCompany.rpt"
                    oRpt.SetParameterValue("userIDParam", crPrm("userIDParam"))
                    oRpt.SetParameterValue("vendorCompanyIDParam", crPrm("vendorCompanyIDParam"))
                    oRpt.SetParameterValue("buyerCompanyIDParam", crPrm("buyerCompanyIDParam"))
                    oRpt.SetParameterValue("dateFromParam", crPrm("dateFromParam"))
                    oRpt.SetParameterValue("dateToParam", crPrm("dateToParam"))
    
            End Select
    
            Me.CrystalReportViewer1.ReportSource = oRpt
    
        End Sub
    
    End Class

    I tried to make the server.mappath hard coded but I still get error below

     Error ID : xwfrbq45sebrparsf1jorn45--2052925431
    Message : Access is denied.
    Error Source : Analysis Server
    Error Stack Trace :
    at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

    Im using the same codes in another page but it works well. Any solution for this?

    Thank you.


     

    Tuesday, August 9, 2011 12:35 AM

Answers

  • User-1364446067 posted

    Hi fali.sheru,

    The error is usually generated when the allcated space for temporary generated Crystal Reports is met.

    You have following options to solve it :

    1. Dispose your report objects everytime they are out of use by calling CrystalReport.Dispose() method. This will flush/ remove the temporary created report files.

    2. Restart your IIS server. This is a temporary solution and solves the issue sometimes.

    3. In the registory of your server, Set PrintJobLimited to -1 for related Crystal Reports version. The default value is 75 which means that 75 of the maximum reports can be temporary created after that it throws error "Load Report failed". Setting it to -1 means indefinite value.

    --

    Hope this helps..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 6:27 AM
  • User-48702869 posted

    1. CR have configured properly.

    2. CrystalReport.Dispose() have been added.

    3. IIS restarted.

    4. Assemblies in web.config is same with the one I have installed.

    5. And finally, users/roles have full access to the report file.

    It still doesn't work for me. So I have altered my codes according to  http://www.anewdevelopment.com/2006/11/crystal-reports-access-is-denied.html and changed identity impersonate to false in my web.config. This works for me.

    Smile Thank you all.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 9:18 PM

All replies

  • User311508580 posted

    Hi fali.sheru,

    Have you make sure that you have configured your CR well? Please make sure crystal report viewer and aspnetclient has been configured well. And you need to run it on Local Service. Please kindly check it. :)

    Tuesday, August 9, 2011 1:30 AM
  • User1759999623 posted

    It appears that you do not have rights to the report.  You need to verify that you are allowed to open the report through your web app.

    Tuesday, August 9, 2011 1:31 AM
  • User-48702869 posted

    Hi fali.sheru,

    Have you make sure that you have configured your CR well? Please make sure crystal report viewer and aspnetclient has been configured well. And you need to run it on Local Service. Please kindly check it. :)

    Following is part of my codes for crystal report viewer.

    <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
        Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    
    <head runat="server">
        <title>Report</title>
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
    </head>
    
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" 
                HasCrystalLogo="false" HasToggleGroupTreeButton="false" DisplayGroupTree="false"
                EnableDatabaseLogonPrompt="false" EnableParameterPrompt="false"/>

     

    It appears that you do not have rights to the report.  You need to verify that you are allowed to open the report through your web app.

    How can I verify that? Sorry Im still not familiar with ASP.Net fully yet. Still pretty new

    Tuesday, August 9, 2011 2:08 AM
  • User-48702869 posted

    OK, the error is rectified helped by http://www.anewdevelopment.com/2006/11/crystal-reports-access-is-denied.html, but now im having a new error which is  "String reference not set to an instance of a String. Parameter name: s".

    Here is my code:

    Dim TempRoot As String = ConfigurationManager.AppSettings("CRTempDir")
            Dim oldTmp As String = System.Environment.GetEnvironmentVariable("TMP")
            System.Environment.SetEnvironmentVariable("TMP", TempRoot)
            Dim crPrm As Hashtable
    
            crPrm = Session("Param")
            Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
            Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim dbConn As TableLogOnInfo = New TableLogOnInfo
            Dim oRpt As ReportDocument = New ReportDocument
            Dim arrTables As Object() = New Object(0) {}
            ReDim arrTables(20)
    
            oRpt.Load(Server.MapPath(rpt)) '("D:\Project\Shell Sarawak\eTravel\Report\viewtr.rpt")
            System.Environment.SetEnvironmentVariable("TMP", oldTmp)
            'oRpt.Load("C:\Inetpub\SVNRepo\SPP\eProcure\Common\Report\outstandPOFrSuppl2.rpt") '& rpt)
            crDatabase = oRpt.Database
            crDatabase.Tables.CopyTo(arrTables, 0)
            crTable = DirectCast(arrTables(0), CrystalDecisions.CrystalReports.Engine.Table)
            dbConn = crTable.LogOnInfo
            dbConn.ConnectionInfo.ServerName = strServerName
            dbConn.ConnectionInfo.DatabaseName = strDBName
            dbConn.ConnectionInfo.UserID = strUN
            dbConn.ConnectionInfo.Password = strPWD
            crTable.ApplyLogOnInfo(dbConn)

     and I get error on following

    dbConn.ConnectionInfo.Password = strPWD

     Please help.

    Thank you.

    Tuesday, August 9, 2011 5:35 AM
  • User-1364446067 posted

    Hi fali.sheru,

    The error is usually generated when the allcated space for temporary generated Crystal Reports is met.

    You have following options to solve it :

    1. Dispose your report objects everytime they are out of use by calling CrystalReport.Dispose() method. This will flush/ remove the temporary created report files.

    2. Restart your IIS server. This is a temporary solution and solves the issue sometimes.

    3. In the registory of your server, Set PrintJobLimited to -1 for related Crystal Reports version. The default value is 75 which means that 75 of the maximum reports can be temporary created after that it throws error "Load Report failed". Setting it to -1 means indefinite value.

    --

    Hope this helps..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 6:27 AM
  • User1196771204 posted

    hi fali,

    Have you made sure you configure your Crystal Report properly? Few things to check:
    1. Please make sure the CR installed on the system matches the CR used on your site
    2. Please make sure the assemblies used on your web.config matches the assemblies installed on your system
    3. Please make sure the FULL TRUST option is enabled on your site
    4. Please make sure your CR site is running under LOCAL SERVICE permission
    5. Please make sure you copy the aspnet_client and crystalreportviewer folders to your operating folder.

    If the report works on your local PC but not on the remote server, clearly the problem is with the underlying server. You need to access the server to perform the steps outlined above!

    Please mark this response as an "answer" if it helps you. Thanks heaps!


    :-)

    Tuesday, August 9, 2011 8:03 AM
  • User1759999623 posted

    In Windows Explorer, look at what users/roles have rights to the report file.  If the default ASP.NET user does not have rights to read the file, then you won't be able to open it.

    Tuesday, August 9, 2011 8:11 PM
  • User-48702869 posted

    1. CR have configured properly.

    2. CrystalReport.Dispose() have been added.

    3. IIS restarted.

    4. Assemblies in web.config is same with the one I have installed.

    5. And finally, users/roles have full access to the report file.

    It still doesn't work for me. So I have altered my codes according to  http://www.anewdevelopment.com/2006/11/crystal-reports-access-is-denied.html and changed identity impersonate to false in my web.config. This works for me.

    Smile Thank you all.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 9:18 PM
  • User1196771204 posted
    hi fali, I am glad to understand that you manage to get it working now.... :-)
    Friday, August 12, 2011 12:01 AM