|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reportviewer: how to display different reports in same viewerreport 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.> Hi Jan!
Did you have any help for your problem? I have exactly the same problems than you. I have spend a lot of hours trying to solve this kingd of problem, but I haven't got any idea what to do. So, if you have got any help or solve already your problem, please, tell us, what was wrong in your code or what did you had to do, that you get everything works perfectly. Regards Mary Show quoteHide quote "Jan DHondt" wrote: > 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.> > >
Other interesting topics
|
|||||||||||||||||||||||