JTSOne
JTSOne

Reputation: 169

VB.NET 2010 RDLC Subreport "Data retrieval failed for the subreport"

Using VB.NET 2010 and SQL Server 2008 R2.

I have inherited an application with a RDLC report. I have not used those before. The report was created and works fine but the originator left out a set of data, a subreport for the "parent" record reported on.

I have tried to add a subreport, point the input parameters of the main to the sub(they use same information). Have the sub use a Dataset that points to a Stored procedure and display the results.

Any attempt to execute (and display) sub report data fails with the message

Data retrieval failed for subreport....located at....Please check the log files for more information.

Off what/where are the log files located?

I can pass in params and as long as I add a dataset w/a stored procedure, I can see the params if I put on report. If I add the stored procedure ...Nothing. I tried a fix found on internet to create a Copy of the XSD's stored procedure call... but that didn't work either.

Main report works fine without Sub.

Thoughts?

What am I missing?

Shouldn't I be able to add a subreport, link up the parameters and have subreport display related information?

Here is my code to call main report:

    Dim adapter As New SqlClient.SqlDataAdapter
    Dim table As New DataTable
    Try
        Cursor.Current = Cursors.WaitCursor


        ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
        ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\IndividualInterviewerDataReport.rdlc"


        Dim ReportParameters(5) As Microsoft.Reporting.WinForms.ReportParameter
        ReportParameters(0) = New Microsoft.Reporting.WinForms.ReportParameter("SurveyName", frmMain.SurveyName)
        ReportParameters(1) = New Microsoft.Reporting.WinForms.ReportParameter("Interviewer", InterviewerId)
        ReportParameters(2) = New Microsoft.Reporting.WinForms.ReportParameter("Panel", PanelMonth)
        '
        '
        ReportParameters(3) = New Microsoft.Reporting.WinForms.ReportParameter("- Version: " + ProductVersion)
        ReportParameters(4) = New Microsoft.Reporting.WinForms.ReportParameter("PanelYear", PanelYear)
        ReportParameters(5) = New Microsoft.Reporting.WinForms.ReportParameter("SurveyNbr", frmMain.SurveyNum)

        ReportViewer1.LocalReport.SetParameters(ReportParameters)
        ReportViewer1.ShowPrintButton = True
        ReportViewer1.ZoomPercent = 100

        Me.spInterviewerDataByPanelTableAdapter.Connection.ConnectionString = My.Settings.DBConnection

        Me.spInterviewerDataByPanelTableAdapter.Fill(Me.CodingControlDataSet.spInterviewerDataByPanel, frmMain.SurveyNum, PanelYear, PanelMonth, InterviewerId)

        Me.ReportViewer1.RefreshReport()

Upvotes: 0

Views: 958

Answers (1)

Ann L.
Ann L.

Reputation: 13965

If I'm remembering correctly, you'll need to handle the SubreportProcessing event of the LocalReport object, and set the subreport data there. You do this by setting a property of the EventArgs parameter for the event handler.

Here's some code (adapted from Microsoft documentation):

'In your report setup code'
AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, _
    AddressOf DemoSubreportProcessingEventHandler

'Event hander
 Public Sub DemoSubreportProcessingEventHandler(ByVal sender As Object, _
 ByVal e As SubreportProcessingEventArgs)

    e.DataSources.Add(New ReportDataSource("DatasetNameInReport", MyDataTable ))
End Sub

Upvotes: 1

Related Questions