none
Reportviewer won't load report RRS feed

  • Question

  • Hi, I’m trying to use the same ReportViewr1 to load a number of reports (not at the same time) using code; I keep getting “a data source instance has not been supplied for the data source ‘ExceptionsDS’” 

    Here’s my code (VB) What am I missing?

     Case enumReportsToSet.ExceptionsReport

         Me.ReportViewer1.Reset()

        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = Fleet_Buddy.ExceptionsReport.rdlc"

    Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("BuddyDataSet_ExceptionsDS", ExceptionsBindingSource))

        Me.ReportViewer1.RefreshReport()

    End Select

    Ivan J

    Saturday, October 30, 2010 1:26 PM

Answers

  • Hi Brian,

    I have found the problem :)

    I used the path BuddyDataSet in the line below when I remove the path and just use ExceptionsDS it finally works.

    Me.ReportViewer1.LocalReport.DataSources.Add(New   Microsoft.Reporting.WinForms.ReportDataSource("BuddyDataSet_ExceptionsDS", ExceptionsBindingSource))

     

    Ivan J

     

    • Marked as answer by Ivan J Sunday, October 31, 2010 5:17 PM
    Sunday, October 31, 2010 5:17 PM

All replies

  • Make sure you remove the old datasources before you try to use the reportviewer again for a different report and datasource..
    Sunday, October 31, 2010 3:19 AM
  • Hi Steven,

    Isn't that what   Me.ReportViewer1.Reset() will do? or is there another command?

     

    Sunday, October 31, 2010 3:43 AM
  • No, it does not clear the DataSources - you need to replace it with

    Me.ReportViewer1.LocalReport.DataSources.Clear()


    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Sunday, October 31, 2010 6:36 AM
  • Added that but it still won't open

    My solution is named: Fleet Buddy

    The Report is named: ExceptionsReport

    when the report was created In the report Wizard

    It was named: ExceptionDS

    DataSource chosen: BuddyDataSet

    Dataset chosen: Exceptions

    What am I doing wrong here or what am I still missing something?

    My code looks like this now:

    Case enumReportsToSet.ExceptionsReport

        Me.ReportViewer1.LocalReport.DataSources.Clear()

        Me.ReportViewer1.Clear()

        Me.ReportViewer1.Reset()

    Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "Fleet_Buddy.ExceptionsReport.rdlc"

    Me.ReportViewer1.LocalReport.DataSources.Add(New   Microsoft.Reporting.WinForms.ReportDataSource("BuddyDataSet_ExceptionsDS", ExceptionsBindingSource))

        Me.ReportViewer1.RefreshReport()

    End Select

    Ivan J

    Sunday, October 31, 2010 7:46 AM
  • Is the dataset name "BuddyDataSet" or "BuddyDataSet_ExceptionDS"? The only other things I see that COULD be a problem, are you reusing the ExceptionsBindingSource too? If so, you'll want to clear it out like you are doing with the report.datasources..

    Here is a small code snippit I have used in the past to achieve the same goal you're trying to reach..

       if (comboBoxSelection.Text == "Appointments - Cancelled")
       {
        rp = new Microsoft.Reporting.WinForms.ReportParameter("EmployeeID", paramName);
        allAppointments = client.GetAppointmentRange(dateTimePickerStart.Value.Date,
         dateTimePickerEnd.Value.Date, "AllLocations", CurrentEmployee.Index)
         .Where(x => x.Status == "Cancelled").OrderBy(x => x.Date_and_Time).ToArray();
        reportDataSource.Name = "DataSet1";
        reportViewer1.LocalReport.ReportEmbeddedResource = "APRN_Client.AppsByLocationDateTime.rdlc";
        reportDataSource.Value = allAppointments;
        reportViewer1.LocalReport.DataSources.Add(reportDataSource);
        reportViewer1.LocalReport.SetParameters(rp);
       }
    
    You can also try creating an actual reportdatasource object, like in the snippit above. Rather than "add(New ReportDataSource....."
    Sunday, October 31, 2010 11:08 AM
  • Performing a Reset will clear the DataSources collection, since it effectively clears out the entire LocalReport object, but that isn't the issue here anyway.  I don't believe the Reset call is necessary in your situation.

    The exception is complaining that no ReportDataSource object has been supplied for the ExceptionsDS data source defined in your report.  Your code is adding a data source for BuddyDataSet_ExceptionsDS, as noted in the first parameter to the ReportDataSource constructor.  It looks like you just need to update this name to the data source defined in the report - ExceptionsDS.

    As an additional note, you could pass in ReportViewer.LocalReport.GetDataSourceNames()[0] to avoid hard coding the data source name in the first place.

    Sunday, October 31, 2010 5:06 PM
    Moderator
  • Hi Brian,

    I have found the problem :)

    I used the path BuddyDataSet in the line below when I remove the path and just use ExceptionsDS it finally works.

    Me.ReportViewer1.LocalReport.DataSources.Add(New   Microsoft.Reporting.WinForms.ReportDataSource("BuddyDataSet_ExceptionsDS", ExceptionsBindingSource))

     

    Ivan J

     

    • Marked as answer by Ivan J Sunday, October 31, 2010 5:17 PM
    Sunday, October 31, 2010 5:17 PM