我试图在运行时切换对象数据源(objectdatasource1 和 objectdatasource2),并在单击 button1 时刷新我的报表查看器。我无法弄清楚如何做到这一点,并且无法使下面的代码正常工作。有任何想法吗?谢谢
Dim dataSetName As String = "MyApplication_ModelObject"
Dim ds As New MyApplication_ModelObjectTableAdapters.DataTableTableAdapter()
Dim rds As New ReportDataSource("MyApplication_ModelObject", ds.GetData())
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(rds)
ReportViewer1.LocalReport.Refresh()