G
Guest
Designing a winform with a reportviewer that shows data for a single .rdlc
report is no problem, the wizords help to setup the datasource, the
bindingsource and the tableadapter instance and bind it to the reportviewer
and .rdlc report.
But I tried to keep the same form to display another report in the same
reportviewer: however I have not worked out how to change the different
datasources and databindings.
here's an example of my code
Private m_Reportdatasource1 As
Microsoft.Reporting.WinForms.ReportDataSource
Private m_Reportdatasource2 As
Microsoft.Reporting.WinForms.ReportDataSource
Private Sub CreateReport1()
If m_Reportdatasource1 Is Nothing Then
m_Reportdatasource1 = New
Microsoft.Reporting.WinForms.ReportDataSource
m_Reportdatasource1.Name = "ds1_tbl1"
m_Reportdatasource1.Value = Me.tbl1BindingSource
End If
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(m_Reportdatasource1)
Me.ReportViewer1.LocalReport.ReportEmbeddedResource =
"MyProject.rpt1.rdlc"
Me.tbl1TableAdapter.Fill(Me.dsAnalysis1.tblAnalysis1)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub CreateReport2()
If m_Reportdatasource2 Is Nothing Then
m_Reportdatasource2 = New
Microsoft.Reporting.WinForms.ReportDataSource
m_Reportdatasource2.Name = "dsAnalysis2_tblAnalysis2"
m_Reportdatasource2.Value = Me.tblAnalysis2BindingSource
End If
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(m_Reportdatasource2)
Me.ReportViewer1.LocalReport.ReportEmbeddedResource =
"MyProject.rpt2.rdlc"
Me.tbl2TableAdapter.Fill(Me.ds2.tbl2)
Me.ReportViewer1.RefreshReport()
End Sub
The first time I refresh the reportviewer it works, the second time I do not
see the report, but I get an error message in the reportviewer , saying there
is no ds instance for the 1st report.
Can anyone point me into the right direction on how to accomplish this?
--
Jan D''Hondt
Jade bvba
Belgium
Database and .NET development
<Toto, I''ve got a feeling we''re not in Kansas anymore.>
report is no problem, the wizords help to setup the datasource, the
bindingsource and the tableadapter instance and bind it to the reportviewer
and .rdlc report.
But I tried to keep the same form to display another report in the same
reportviewer: however I have not worked out how to change the different
datasources and databindings.
here's an example of my code
Private m_Reportdatasource1 As
Microsoft.Reporting.WinForms.ReportDataSource
Private m_Reportdatasource2 As
Microsoft.Reporting.WinForms.ReportDataSource
Private Sub CreateReport1()
If m_Reportdatasource1 Is Nothing Then
m_Reportdatasource1 = New
Microsoft.Reporting.WinForms.ReportDataSource
m_Reportdatasource1.Name = "ds1_tbl1"
m_Reportdatasource1.Value = Me.tbl1BindingSource
End If
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(m_Reportdatasource1)
Me.ReportViewer1.LocalReport.ReportEmbeddedResource =
"MyProject.rpt1.rdlc"
Me.tbl1TableAdapter.Fill(Me.dsAnalysis1.tblAnalysis1)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub CreateReport2()
If m_Reportdatasource2 Is Nothing Then
m_Reportdatasource2 = New
Microsoft.Reporting.WinForms.ReportDataSource
m_Reportdatasource2.Name = "dsAnalysis2_tblAnalysis2"
m_Reportdatasource2.Value = Me.tblAnalysis2BindingSource
End If
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(m_Reportdatasource2)
Me.ReportViewer1.LocalReport.ReportEmbeddedResource =
"MyProject.rpt2.rdlc"
Me.tbl2TableAdapter.Fill(Me.ds2.tbl2)
Me.ReportViewer1.RefreshReport()
End Sub
The first time I refresh the reportviewer it works, the second time I do not
see the report, but I get an error message in the reportviewer , saying there
is no ds instance for the 1st report.
Can anyone point me into the right direction on how to accomplish this?
--
Jan D''Hondt
Jade bvba
Belgium
Database and .NET development
<Toto, I''ve got a feeling we''re not in Kansas anymore.>