Problem with rdlc subreport - data retrieval fail

kbutchm

Member
Joined
May 12, 2011
Messages
10
Programming Experience
1-3
Hi,I am having a problem when using subreports.I'm using MS2010 and rdlc reports. I have a designed a report and added a subreport to it.Both reports work perfectly independently, but when I add the sub report to the main report and link it using the subreport properties, I get this error:"Data retrieval failed for the subreport, located at ....., Please check the log files for more information"Has anyone seen this problem before or am I leaving something out?Thanks in advance
 
I found this code which helps with subreports

Imports Microsoft.Reporting.WinForms


Public Class Form1


Dim dt As DataTable = Nothing
Public Property strReport As String


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Dim rptDataSource As ReportDataSource


strReport = "Report1"


Try




With Me.ReportViewer1.LocalReport
.ReportPath = "\Reports\" & strReport & ".rdlc"
.DataSources.Clear()
End With


Select Case strReport
Case "Report1"
Dim ds As New Database.myDataSet
Dim da As New Database.DatabaseDataSetTableAdapters.myTableAdapter


AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubreportProcessingEventHandler


da.Fill(ds.myTable)


rptDataSource = New ReportDataSource("myDataSet", ds.Tables("mDataset"))
End Select


Me.ReportViewer1.LocalReport.DataSources.Add(rptDataSource)


Me.ReportViewer1.RefreshReport()


Catch ex As Exception


MessageBox.Show(ex.ToString)


End Try
End Sub


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


Try
Dim ds As New Database.DataSet1
Dim da As New Database.DatabaseDataSetTableAdapters.TableAdapterOne




da.Fill(ds.OtherTable)


e.DataSources.Add(New ReportDataSource("OtherDataSet", ds.Tables("OtherTable")))


Catch ex As Exception


MessageBox.Show(ex.ToString)


End Try


End Sub
End Class
 
Back
Top