在单个报表查看器中切换多个报表(.rdlc)

时间:2012-09-18 02:59:45

标签: vb.net visual-studio-2005 rdlc

我有2个报告,“report1.rdlc”“report2.rdlc”。我希望能够在单个报告查看器中交换它们(“rv_1”)。

我还有3个按钮:
确实: btn_1

rv_1.LocalReport.ReportEmbeddedResource = "Application1.Report1.rdlc"
rv_1.RefreshReport()

btn_2

rv_1.LocalReport.ReportEmbeddedResource = "Application1.Report2.rdlc"
rv_1.RefreshReport()
确实:

btn_3

dim rds as new ReportDataSource
rds.name = 
rds.value = 
rv_1.reset()
rv_1.LocalReport.DataSources.add(rds)
rv_1.RefreshReport()

无论我为rds.namerds.value投放了什么,它都会留给我

  

尚未为数据源'dataSetName_TableName'提供数据源实例。

我需要做些什么才能使其正常工作?

1 个答案:

答案 0 :(得分:0)

Private Sub REPORT1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
   If CON.State = ConnectionState.Closed Then : 
     CON.Open() : 
   End If 
   CMD.Connection = CON 
   CMD.CommandText = "SELECT * FROM accounts" 
   DR = CMD.ExecuteReader 
   If DR.HasRows Then 
  Do While (DR.Read) 
    Me.DataSet1.TblData.AddTblDataRow(DR("FNAME"), DR("LNAME"), DR("MI")) 
  Loop 
 End If Me.ReportViewer1.LocalReport.ReportPath = "Report1.rdlc" 
 Me.ReportViewer1.RefreshReport() 
End Sub