locked
switching reports problem in local mode, windows form environment RRS feed

  • Question

  • Hi,

    I'm using a radio button for user to pick one out of two reports to run.  Both Report1 and Report2 use the same data source just present them in different ways.

    However, only the first one picked shown in the report viewer (no matter which one first).  i.e. Pick another report to run and the report viewer always shows the first one.

    Any step that I missed?  Thanks.

     

    Private Sub btnGetReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetReport.Click  

          If rbHistory.Checked = True Then
                Me.ReportViewer.LocalReport.ReportEmbeddedResource = "ServerManager.Report1.rdlc"
            Else
                Me.ReportViewer.LocalReport.ReportEmbeddedResource = "ServerManager.Report2.rdlc"
            End If

            Me.PrintHistoryTableAdapter.FillByDateRange(Me.dsPrintHistory.PrintHistory, dtpStartDate.Text, dtpEndDate.Text)

    Me.ReportViewer.RefreshReport()

        End Sub

    Thursday, March 16, 2006 3:35 AM

Answers

  • My mistake... you need to add it before you set the report path.  Reset will give you a brand new instance of LocalReport and ServerReport, so the path that you set got cleared out by the Reset call too.
    Thursday, March 16, 2006 5:04 PM

All replies

  • Call ReportViewer.Reset() before the RefreshReport call.  This will clear out the old report snapshot.
    Thursday, March 16, 2006 6:01 AM
  • Added the ReportViewer.Reset() right above the RefreshReport call

    now it shows - "the source of the report definition has not been specified"

    any idea?  Thanks

    Thursday, March 16, 2006 6:06 AM
  • My mistake... you need to add it before you set the report path.  Reset will give you a brand new instance of LocalReport and ServerReport, so the path that you set got cleared out by the Reset call too.
    Thursday, March 16, 2006 5:04 PM
  • I have a similar issue, however using Reset does clear the path but the new path set does not get used.
    The reportviewer1 was initial set to use the "DeviceMonitorList.rdlc",
    I get a blank report with all the buttons disabled. and the message.
    "A data source instance has not been supplied for the data source "Emerson_AMS_Private_AlertMonitor_DeviceConfig".

    Any help would be appreciated.
    Also Microsoft.ReportViewer.WinForms.dll has version 8.0.50727.817

    Thanks
    Prasanna

    try
                {
                    //reset the report viewer properties
                    reportViewer1.Reset();
                    //set the report viewer to process a local report
                    this.reportViewer1.ProcessingMode = ProcessingMode.Local;

                    if (ReportType.Equals("DeviceMonitorList"))
                    {
                        DeviceConfigBindingSource.DataSource = m_DeviceConfigs;
                        reportViewer1.LocalReport.ReportPath = "DeviceMonitorList.rdlc";
                        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(ReportType,
                                                                            DeviceConfigBindingSource.DataSource));
                    }
                    if (ReportType.Equals("AlertList"))
                    {
                        this.DeviceAlertBindingSource.DataSource = m_DeviceAlerts;
                        this.reportViewer1.LocalReport.ReportPath = @"Alerts.rdlc";
                        this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(ReportType,
                                                                            this.DeviceAlertBindingSource.DataSource));
                    }
                    // Anchor the report to the form so that it resizes with the form.
                    reportViewer1.Anchor = (AnchorStyles.Bottom |
                                                 AnchorStyles.Right |
                                                 AnchorStyles.Top |
                                                 AnchorStyles.Left);


                    // Display the report.
                    reportViewer1.RefreshReport();
                    //reportViewer1.Refresh();
    Monday, June 4, 2007 7:30 PM
  • The report definition files contain information about the dataset they were created with - I think it's some mangling of the dataset name and the particular data table the report uses. E.g. I have a BookLibraryDataset dataset and a StockQuery datatable and my report definition file (report1.rdlc) contains this:

     <DataSetName>BookLibraryDataSet_StockQuery</DataSetName>

    My code looks like this:
        Me.ReportViewer1.Reset()
        Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource
        ReportDataSource1.Name = "BookLibraryDataSet_StockQuery"
        ReportDataSource1.Value = Me.BookLibraryDataSet1.StockQuery
        Me.ReportViewer1.LocalReport.DataSources.Clear()
        Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)
        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewerTest.Report1.rdlc"
        Me.ReportViewer1.RefreshReport()

    The    
    ReportDataSource1.Name = "BookLibraryDataSet_StockQuery"
    line has to match the report definition file or it won't file the data source and you'll get a message similar to :

    A data source instance has not been supplied for the data source "Whatever the report definition file is expecting".

    Wednesday, June 27, 2007 3:58 PM