0
我創建了一個報告(未嚮導)的VB2010,我設置使用數據集編程,我想一個過濾選項添加到報表過濾器或設置參數編程上的報告(RDLC)
的數據源原代碼: 此代碼顯示所有的與沒有過濾
Dim rptDataSource As ReportDataSource
With rptReportViewer.LocalReport
.ReportPath = "Reports\" & strReport & ".rdlc"
.DataSources.Clear()
End With
Select Case strReport
Case "rptProducts"
Dim ds As New dsProducts
Dim da As New dsProductsTableAdapters.ProductsTableAdapter
da.Fill(ds.Products)
'//use the same name as defined in the report Data Source Definition
rptDataSource = New ReportDataSource("ProductsDataSet", ds.Tables("Products"))
End Select
rptReportViewer.LocalReport.DataSources.Add(rptDataSource)
rptReportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
rptReportViewer.ZoomMode = ZoomMode.Percent
rptReportViewer.RefreshReport()
數據
我做了一些google搜索,我插入一些代碼
修改後的代碼
Dim rptDataSource As ReportDataSource
**'this code inserted**
Dim FilterBrand As New ReportParameter("FilterBrand", txtfilter.Text)
With rptReportViewer.LocalReport
.ReportPath = "Reports\" & strReport & ".rdlc"
.DataSources.Clear()
End With
Select Case strReport
Case "rptProducts"
Dim ds As New dsProducts
Dim da As New dsProductsTableAdapters.ProductsTableAdapter
da.Fill(ds.Products)
'//use the same name as defined in the report Data Source Definition
rptDataSource = New ReportDataSource("ProductsDataSet", ds.Tables("Products"))
End Select
rptReportViewer.LocalReport.DataSources.Add(rptDataSource)
**'this code inserted**
rptReportViewer.LocalReport.SetParameters(New ReportParameter() {FilterBrand})
rptReportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
rptReportViewer.ZoomMode = ZoomMode.Percent
rptReportViewer.RefreshReport()
報告說,報告處理過程中出現的錯誤,是什麼問題,怎麼我設置的過濾程序?
感謝