问题
I know this question has been asked before, but all questions were for reports being accessed using C# or vb.net code. My problem is that i am building and accessing the report using Business Intelligence studio, I am basically trying to add a sub report for a report, and I made sure from the parameters and they are ok. However when i try to access the report containing the subreport, I get the error "Data retrieval failed for the subreport, 'Subreport1'".
I also tried deleting the .data files but the same problem persisted.
回答1:
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.
回答2:
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.
回答3:
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
回答4:
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
回答5:
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
来源:https://stackoverflow.com/questions/23061147/getting-the-error-data-retrieval-failed-for-the-subreport-subreport1-while