none
report viewer error RRS feed

  • Question

  • I am trying to swap reports in a report viewer control at runtime but i keep getting this error: A datasource instance has not been supplied for the datasource instance 'mydatasource_patients'

    I am using VS 2008 with vb and the application is a winforms app. Here is the code i have been using so far;

            Select Case cbReportType.SelectedItem
    Case "Admitted Patients"

    myReportViewer.Reset()
    myReportViewer.LocalReport.Dispose()
    Dim Rds As New ReportDataSource("AdmittedPatients", ADmittedPatientsDataSet.Patients)
    myReportViewer.LocalReport.DataSources.Clear()
    myReportViewer.LocalReport.DataSources.Add(Rds)
    myReportViewer.LocalReport.ReportPath = "Admitted Patients.rdlc"

    myReportViewer.LocalReport.Refresh()
    myReportViewer.RefreshReport()

    Case "All Patients"
    myReportViewer.Reset()
    myReportViewer.LocalReport.Dispose()
    Dim Rds As New ReportDataSource("AllPatients", ReportsDataSet.Patients)
    'myReportViewer.LocalReport.DataSources.Clear()
    myReportViewer.LocalReport.DataSources.Add(Rds)
    myReportViewer.LocalReport.ReportPath = "RegisteredPatients.rdlc"

    myReportViewer.LocalReport.Refresh()
    myReportViewer.RefreshReport()

    End Select

    just your average amatuer vb programmer.
    Monday, June 22, 2009 4:36 PM

Answers

  • You have supplied data for the "AdmittedPatients" and "AllPatients" data sources, but you haven't supplied one for the "mydatasource_patients" data source.  The names you supply to the ReportDataSource object need to match the names defined in the RDLC.  Either you need to add another ReportDataSource for mydatasource_patients, or you have named one of the existing ones incorrectly.

    • Marked as answer by NanaKwame Monday, July 6, 2009 11:49 AM
    Monday, June 22, 2009 5:07 PM
    Moderator