Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
Hi all,
I have a problem when I add a subreport to my report the subreport doesn't work.
At the moment I don't need pass parameters (in the future yes but at the moment I will stay happy if work without parameters Smile | :) )

By separate works both reports (report and subreport), but when I add subreport this fail.
I have 3 datasource with a lot information, with a list that user choose I must send 1,2,3... or x bills with informations of client and details about that bought.
At the moment I only use 2 datasource and a subreport but the idea when it work is have 2 subreport into main report.
The main report use adapter1, the subreport adapter2.
I send you the code for your review, I am sure that is a stupid error but I took a lot hours and I didn't find it (the visual studio 2008 doesn't give me errors).
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim listaIds As New List(Of Integer)
            If Not Session("listaIdPropietarios") Is Nothing Then
                listaIds = Session("listaIdPropietarios")
            End If
        Dim FInicio, FFinal As Date
        Dim adapter1 As New DataSetProductsTableAdapters.P_ObtenerFacturaSTableAdapter
        Dim adapter2 As New DataSetProductsTableAdapters.P_DetalleFacturaTableAdapter
        Dim adapter3 As New DataSetProductsTableAdapters.P_DetalleIvaFacturaTableAdapter
        AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SetSubDataSource
        Dim tabla As DataSetProducts.P_ObtenerFacturaSDataTable = adapter1.GetData(Convert.ToInt32(Session("Remesa")))
        '-----------------Cojo todos los clientes seleccionados--------------
        'Ahora hay que hacer un for next de todos los id_clientes seleccionados
        Dim tablaFinal As New DataSetProducts.P_ObtenerFacturaSDataTable
        Dim tablaFinal2 As New DataSetProducts.P_DetalleFacturaDataTable
        Dim tablaFinal3 As New DataSetProducts.P_DetalleIvaFacturaDataTable
        If Not tabla Is Nothing Then
            For Each Etiqueta As DataSetProducts.P_ObtenerFacturaSRow In tabla.Rows
                If listaIds.Contains(Etiqueta.Id_Cliente) Then
                    'Miramos que fechas tiene facturado en en esa remesa ese cliente
                    Dim SaberFechas As DataTable = Recibos.ObtenerDetalleRemesa(Etiqueta.Id_Cliente, Session("Remesa"))
                    FInicio = SaberFechas(0)("FInicio")
                    FFinal = SaberFechas(0)("FechaConfeccion")
                    'Recogemos todos sus pedidos de ese periodo
                    Dim tabla2 As DataSetProducts.P_DetalleFacturaDataTable = adapter2.GetData(Convert.ToInt32(Etiqueta.Id_Cliente), FInicio, FFinal)
                    'Añadimos a una tablafinal2 los pedidos de ese usuario, luego los de otro  y los de otro
                    If Not tabla2 Is Nothing Then
                        For Each Etiqueta2 As DataSetProducts.P_DetalleFacturaRow In tabla2.Rows
                    End If
                    Dim tabla3 As DataSetProducts.P_DetalleIvaFacturaDataTable = adapter3.GetData(Convert.ToInt32(Etiqueta.Id_Cliente), FInicio, FFinal)
                    If Not tabla3 Is Nothing Then
                        For Each Etiqueta3 As DataSetProducts.P_DetalleIvaFacturaRow In tabla3.Rows
                    End If
                End If
        End If
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Informes/Factura2.rdlc")
        ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSetProducts_P_ObtenerFacturaS", tablaFinal))
        ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSetProducts_P_DetalleFactura", tablaFinal2))
        ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSetProducts_P_DetalleIvaFactura", tablaFinal3))
        Dim mimeType As String = ""
        Dim Encoding As String = ""
        Dim extension As String = ""
        Dim warnings() As Microsoft.Reporting.WebForms.Warning
        Dim streamids() As String
        Dim bytes As Byte() = ReportViewer1.LocalReport.Render("Pdf", Nothing, mimeType, Encoding, extension, streamids, warnings)
        Response.ContentType = "application/pdf"
        Response.AddHeader("Content-Length", bytes.Length.ToString())
        Response.AddHeader("Content-Disposition", "attachment; filename=" &amp; "FacturaS.pdf")
    Catch ex As Exception
    End Try
End Sub
Protected Sub SetSubDataSource(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
        Dim o As ObjectDataSource = New ObjectDataSource("DataSetProductsTableAdapters.P_DetalleFacturaTableAdapter", "GetData")
        e.DataSources.Add(New ReportDataSource("DataSetProducts_P_DetalleFactura", o))
    Catch ex As Exception
    End Try
End Sub

Posted 2-Apr-11 11:21am
thatraja at 5-Apr-11 13:42pm
Check the crystal reports event log viewer & then let us know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200
0 OriginalGriff 465
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200

Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 2 Apr 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100