Getting the error “Data retrieval failed for the subreport, 'Subreport1'” while trying to preview a report from Business Intelligence Studio

梦想与她 提交于 2019-12-05 07:25:35

I faced similar issue in past and in my case below were the culprit's

1] Parameter from main report is sending null value to sub report.

2] Data type of parameter were different than actual data type.

Please check if you are doing the same.

I had the same problem when the dataset’s subreport filters the data by the "Filters" functionality (Filter tab), but when change the filter method by the use of sql parameters (Parameters Tab) it Works.

I faced this problem when I was not passing the data source for the subreport. This answer helped me https://stackoverflow.com/a/8924617/4795214

I was using filters inside the subreport but after doing some research I applied the filter directly into the BindingSource and it worked for me. Here is my code if it helps:

Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
        Dim nID As Integer = 0
        Select Case e.ReportPath
            Case "rptBilans_CU"
                nID = e.Parameters.Item(0).Values(0)
                Q_Bilans_CUBindingSource.Filter = "IDPATIENT = " & nID
                e.DataSources.Add(New ReportDataSource("DataSetCompany", Me.DetailSocieteBindingSource))
                e.DataSources.Add(New ReportDataSource("DataSet1", Me.Q_Bilans_CUBindingSource))
            Case "rptBilans_Bacterio"
                nID = e.Parameters.Item(0).Values(0)
                Q_Bilans_BacterioBindingSource.Filter = "IDPATIENT = " & nID
                e.DataSources.Add(New ReportDataSource("DataSetCompany", Me.DetailSocieteBindingSource))
                e.DataSources.Add(New ReportDataSource("DataSet1", Me.Q_Bilans_BacterioBindingSource))
            Case "rptBilans_FNS"
                nID = e.Parameters.Item(0).Values(0)
                Me.Q_Bilans_FNSBindingSource.Filter = "IDPATIENT = " & nID
                e.DataSources.Add(New ReportDataSource("DataSetCompany", Me.DetailSocieteBindingSource))
                e.DataSources.Add(New ReportDataSource("DataSet1", Me.Q_Bilans_FNSBindingSource))
        End Select
    End Sub

I had same issue with sub-reports error "Data retrieval failed for sub report" I found it was in my case everything to do with my login, i was not using sql server login and that was the issue it kept on prompting me for login every now and then. However i Deployed the reports all of them 4 sub reports and one main report, went in the troubled sub report and changed the setting for data source CREDENTIAL STORED SECURELY IN THE REPORT SERVER

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!