locked
Load Report Failed in Crystal RRS feed

  • Question

  • User734945725 posted

    This is my enviroment: App server with Crystal Reports 13 and IIS 7, it has Windows Server 2008 R2. DB Server with SQL 2008. The app was built with ASP.Net 2010 with VB and Ajax.

    I have an aspx with four controls in order to set the parameters needed to load data into a Crystal Report Source (Date1, Date2, DropDownList, Button). The Crystal Viewer and Report Source are into the same page.

    Controls:

    <asp:TextBox ID="txtFechaInicio" runat="server" AutoPostBack="True"></asp:TextBox>
                                    
       <asp:TextBox ID="txtFechaFinal" runat="server" AutoPostBack="True"></asp:TextBox>
                                 
       <asp:ComboBox ID="cbDptos" runat="server" AutoCompleteMode="Suggest" AutoPostBack="False"
                                        DropDownStyle="DropDownList">
                                    </asp:ComboBox>
                            
    <asp:ImageButton ID="cmdGeneracion" runat="server" ImageUrl="~/imagenes/GenerarInforme.png" />
    
          <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
                            <Report FileName="Reportes\rptMontosXDptoXFecha.rpt">
                            </Report>
                        </CR:CrystalReportSource>
    
         <CR:CrystalReportViewer ID="crReportFechas" runat="server" AutoDataBind="true" EnableParameterPrompt="False"
                            HasCrystalLogo="False" HasDrilldownTabs="False" HasRefreshButton="True" HasToggleGroupTreeButton="False"
                            HasToggleParameterPanelButton="False" Height="1202px" PageZoomFactor="83" ReportSourceID="CrystalReportSource1"
                            ToolPanelView="None" Visible="False" />

    When page loads at first time, the report shows data according with the parameters specified in the page load event.

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
               If IsPostBack = False Then
                    cargadatos(Date.Today.AddDays(-30), Date.Today, CInt(cbDptos.SelectedValue))
                    txtFechaInicio.Text = Date.Today.AddDays(-30)
                    txtFechaFinal.Text = Date.Today.Date
    
                Else
                    cargadatos(txtFechaInicio.Text, txtFechaFinal.Text, (cbDptos.SelectedValue))
                End If
            Catch ex As Exception
                mensajeSistema(ex.Message, Mensajes.TipoMensaje.eerror)
            End Try
        End Sub

    But, when I use the controls to set the parameters needed to get a second report, I click the button to load the report again and I get the following error: LOAD REPORT FAILED

        Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdGeneracion.Click
            Try
                crReportFechas.Visible = True
                cargadatos(txtFechaInicio.Text, txtFechaFinal.Text, (cbDptos.SelectedValue))
            Catch ex As Exception
                mensajeSistema("Error al cargar los datos.", Mensajes.TipoMensaje.eerror)
            End Try
    
        End Sub

    Additionally, this is the Unload Event:

    Protected Sub Page_unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
    
            Try
                If Not IsDBNull(objRep) And objRep.IsLoaded Then
                    crReportFechas.Dispose()
                    crReportFechas = Nothing
                    objRep.Close()
                    objRep.Dispose()
                End If
                GC.Collect()
            Catch ex As Exception
    
            End Try
        End Sub

    And this is the procedure to query the DB and load it into Report Source:

     Private Sub cargadatos(ByVal fechainicio As Date, ByVal fechafinal As Date, ByVal idDpto As Integer)
            Try
    
                'objRep.DataSourceConnections(0).SetConnection(ConfigurationManager.AppSettings("ServerBd"), ConfigurationManager.AppSettings("NameBD"), True)
                objRep.DataSourceConnections(0).SetConnection(ConfigurationManager.AppSettings("ServerBd"), ConfigurationManager.AppSettings("NameBD"), ConfigurationManager.AppSettings("UserBD"), ConfigurationManager.AppSettings("PasswordBD"))
    
                objRep.SetParameterValue(0, idDpto)
                objRep.SetParameterValue(1, fechainicio)
                objRep.SetParameterValue(2, fechafinal)
    
                crReportFechas.ReportSource = objRep
    
                Session("Reporte") = objRep
    
            Catch ex As Exception
                mensajeSistema("No se ha podido cargar los datos correctamente. Por favor intente de nuevo.", Mensajes.TipoMensaje.eerror)
            End Try
    
        End Sub

    Any help would be apreciated.

    Friday, April 12, 2013 7:13 PM

Answers

  • User-1137493631 posted

    please have lookinto this thread it could be useful to you

    http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/438b3ee8-9854-40b8-ac8f-cadbabff455d/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 12, 2013 7:58 PM
  • User1196771204 posted

    Hi maikol

    Based on the error message you experienced, the issue can be caused by many factors:

    1. The crystal report version installed on your server does not match the version used on your code
    2. The crsytal report assemblies installed on the server do not match with the assemblies specified on your web.config.

    Once you get these 2 issues sorted out, please make sure that:

    1. You need to set LOCAL SERVICE on your app pool
    2. You need to enable full trust mode on your operating folder.

    For crystal report hosting, you can always consider asphostcentral.com.

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 25, 2013 3:58 AM

All replies

  • User-1137493631 posted

    please have lookinto this thread it could be useful to you

    http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/438b3ee8-9854-40b8-ac8f-cadbabff455d/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 12, 2013 7:58 PM
  • User589263704 posted

    The code worked for me without database prompting:

    Dim reportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument 'load report reportDocument.Load("C:\Documents and Settings\Administrator\Desktop\customer.rpt") 'set user-id/password reportDocument.SetDatabaseLogon("Admin", "abc") 'bind to viewer Me.CrystalReportViewer1.ReportSource = reportDocument

    The report uses an Access database connected via OLEDB.

    See Also

    Sunday, April 21, 2013 2:57 PM
  • User1196771204 posted

    Hi maikol

    Based on the error message you experienced, the issue can be caused by many factors:

    1. The crystal report version installed on your server does not match the version used on your code
    2. The crsytal report assemblies installed on the server do not match with the assemblies specified on your web.config.

    Once you get these 2 issues sorted out, please make sure that:

    1. You need to set LOCAL SERVICE on your app pool
    2. You need to enable full trust mode on your operating folder.

    For crystal report hosting, you can always consider asphostcentral.com.

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 25, 2013 3:58 AM