none
Sub-Report Framework 4.0 RRS feed

  • Question

  • Hi all,
    I have ASP.NET web application(vs 2010). I'm trying to use subreport with reportviewer. The report is working with my machine, it returns both the main and sub report. But when I deplyed to web server, the main report display, but not the subreport and no error indicate. I did something like this with VS2005 and deployed to web server without any problems. Here is my coding:

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

          Dim ReportViewer1 As New ReportViewer

            Dim rptDataSourceMain As New ReportDataSource("dsSRC", GetDataSet("p_SRC_completed_main").Tables(0))

            With ReportViewer1
                .ProcessingMode = ProcessingMode.Local
                .AsyncRendering = False
                .LocalReport.ReportPath = "content\SRC.rdlc"
                .LocalReport.DataSources.Clear()
                .LocalReport.DataSources.Add(rptDataSourceMain)
            End With

            ' HANDLE the sub-report
            AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SetSubDataSource

            ReportViewer1.LocalReport.Refresh()

            Try
                Dim deviceInfo As String = "<DeviceInfo>" & _
                                "<OutputFormat>PDF</OutputFormat>" & _
                                "<PageWidth>8.5in</PageWidth>" & _
                                "<PageHeight>11in</PageHeight>" & _
                                "<MarginTop>0.5in</MarginTop>" & _
                                "<MarginLeft>0.75in</MarginLeft>" & _
                                "<MarginRight>0.4in</MarginRight>" & _
                                "<MarginBottom>0in</MarginBottom>" & _
                                "</DeviceInfo>"

                Dim formatPDF As Byte() = ReportViewer1.LocalReport.Render("PDF", deviceInfo, Nothing, Nothing,Nothing, Nothing, Nothing)

                Response.Clear()
                Response.ContentType = ""
                Response.AddHeader("content-disposition", "attachment; filename=SRC.pdf")
                Response.BinaryWrite(formatPDF)
                Response.End()

            Catch ex As Exception
                Response.Write("ERROR:" & ex.ToString)

            End Try

        End Sub
       
        Protected Sub SetSubDataSource(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

            e.DataSources.Add(New ReportDataSource("dsSRCsub", GetDataSet("p_SRC_completed_sub").Tables(0)))

        End Sub

        Protected Function GetDataSet(ByVal spName As String) As DataSet

            GetDataSet = Nothing

            Dim cnnPath As String = ConfigurationManager.ConnectionStrings("cnPath").ConnectionString
            Dim cnn As New SqlConnection(cnnPath)
            Dim cmd As New SqlCommand
            Dim ds As New DataSet
            Dim da As SqlDataAdapter

            With cmd
                .Connection = cnn
                .CommandType = CommandType.StoredProcedure
                .CommandText = spName
                .Parameters.Add("@util_id", SqlDbType.Int).Value = 1990
            End With
            Try
                cnn.Open()
                da = New SqlDataAdapter(cmd)
                da.Fill(ds)
                GetDataSet = ds

            Catch ex As Exception
                Response.Write("ERROR: " & ex.ToString)
                GetDataSet = Nothing

            Finally
                cmd.Dispose()
                cnn.Close()
                cnn.Dispose()

            End Try

        End Function

    Any solutions for this problems in VS2010.
    Thanks.
    Monday, August 30, 2010 3:45 PM