none
RDLC Subreport data retrieval error. RRS feed

  • Question

  • I know this question has been asked before, and I've looked / tried all of their suggestions but can't seem to resolve the error. I'm relatively new to rdlc reports, but have simple reports without subreports working just fine. My boss has looked at my code and seems to think I am doing it correctly. It's not throwing an exception. The subreport works when used as the main report, and I am using the subreportprocessing  event handler. I am using two separate datasources, one for the main report and one for the subreport. I have tried using just one datasource since the stored procs are in the same database, but that hasn't worked either. I have the correct number of parameters being passed to the subreport in the rdlc designer. Also seem to be passing in the correct values when I trace the code. Not really sure what else I could be doing wrong. Any help would be greatly appreciated. Here is my code:

    Public Class Form1
        Dim UserName As String = "Taminnie"
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'ELLWarehouseDataSet.usp_CycleCountWorkBench_getCycleCountItems' table. You can move, or remove it, as needed.
            Me.usp_CycleCountWorkBench_getCycleCountItemsTableAdapter.Fill(Me.ELLWarehouseDataSet.usp_CycleCountWorkBench_getCycleCountItems, UserName)
            'TODO: This line of code loads data into the 'ELLWarehouseSubDataSet.usp_CycleCountWorkBench_getCycleCountItemsReport' table. You can move, or remove it, as needed.
            Me.usp_CycleCountWorkBench_getCycleCountItemsReportTableAdapter.Fill(Me.ELLWarehouseSubDataSet.usp_CycleCountWorkBench_getCycleCountItemsReport, UserName, Item)
            'Dim Item As String
           
            Dim param(0) As Microsoft.Reporting.WinForms.ReportParameter
            param(0) = New Microsoft.Reporting.WinForms.ReportParameter("UserName", UserName)
            param(1) = New Microsoft.Reporting.WinForms.ReportParameter("Item", Item)
            ReportViewer1.LocalReport.SetParameters(param)

            'Me.ReportViewer1.LocalReport.LoadSubreportDefinition()

            AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, AddressOf MySubreportEventHandler

            'ReportViewer1.LocalReport.Refresh()
            Me.ReportViewer1.RefreshReport()
        End Sub

        Public Sub MySubreportEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

            Try
                e.DataSources.Clear()
                Dim partsDS As New RDLCReportTest.ELLWarehouseSubDataSet
                Dim partsDA As New  RDLCReportTest.ELLWarehouseSubDataSetTableAdapters.usp_CycleCountWorkBench_getCycleCountItemsReportTableAdapter
                partsDA.Fill(partsDS.usp_CycleCountWorkBench_getCycleCountItemsReport, e.Parameters(1).Values(0), e.Parameters(0).Values(0))

                e.DataSources.Add(New ReportDataSource("ELLWarehouseSubDataSet_usp_CycleCountWorkBench_getCycleCountItemsReport", partsDS.Tables(0)))
            Catch ex As Exception
                Label1.Text = ex.ToString()
            End Try

            'Dim p As ReportParameterInfoCollection = e.Parameters
            'Dim Count As Integer = p.Count
        End Sub
    End Class

    Tuesday, June 16, 2015 3:03 PM

All replies

  • Also I'm using VS 2012, SQL server 2014 management studio, and have reportviewer version 11 references in my project. 
    Tuesday, June 16, 2015 3:06 PM