我有一个显示费用的报告,还有一个子报告以显示所有费用支出。这就是我将数据传递到主报告和子报告的方式
Dim datasource As New ReportDataSource("Expenses", Ds.Tables(0))
Me.ReportViewer1.LocalReport.ReportPath = "../../Reports/Expenses.rdlc"
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "../../Reports/Expenses.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(datasource)
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SetSubDataSource
Me.ReportViewer1.LocalReport.Refresh()
Me.ReportViewer1.RefreshReport()
Me.Show()
End If
End Sub
Public Sub SetSubDataSource(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
Dim Ds As New DataSet
Call gSetDatabaseConnection()
Dim sqlcmd As New SqlCommand
With sqlcmd
.CommandType = CommandType.StoredProcedure
.CommandText = "CV_GetPay_BY_EXP"
.Connection = gSqlConncetion
.Parameters.Add(New SqlParameter("@iExp", SqlDbType.Int))
.Parameters("@iExp").Direction = ParameterDirection.Input
.Parameters("@iExp").Value = CType(e.Parameters(0), ReportParameterInfo).Values(0) '11747
Dim sqladp As New SqlDataAdapter(sqlcmd)
sqladp.Fill(Ds)
gSqlConncetion.Close()
End With
Dim datasource As New ReportDataSource("Payments", Ds.Tables(0))
Dim path As String
path = e.ReportPath
e.DataSources.Add(datasource)
End Sub
答案 0 :(得分:1)
弄清楚了 当我插入子报表时,应将其插入组中以在每一行之后重复。