none
ReportViewer control not displaying records from local DataSet RRS feed

  • Question

  • Hey everyone,

    I'm having some trouble loading a DataSet into a ReportViewer control set to Local ProcessingMode.

    Background Info: I have a dataset (BookData) backed by a SQL Server 2005 Express database. The dataset structure is identical to the database backend. There are 3 tables, "Book", "Page", and "Book_To_Page". These tables have the following structures:
    Book: book_id (PK), title, book_object, book_description, date_last_accessed
    Page: page_id (PK), title, page_object, dataset_table
    Book_To_Page: book_to_page_id (PK), book_id (FK), page_id (FK), page_number, page_tip

    book_id and page_id fields are of type nchar(100)
    book_object, page_object, dataset_table, and name fields are of type nvarchar(200)
    page_to_book_id is a 32-bit integer with identity(1,1)
    page_number is a 32-bit integer
    book_description and page_tip fields are nvarchar(MAX)
    date_last_accessed is datetime

    My code sucessfully populates all of the tables in BookData. It then encapsulates BookData with a DataViewManager object and applies filters if necessary. It then connects a series of BindingSource objects to the DVM, so that forms & reports can display the filtered data.

    I tested the loading process by assigning each binding source to a DataGridView and checking the results. I also monitored the data using several watches and breakpoints. Long story short: everything up to this point works dandy.

    However, when I attempt to display the data within a report (in a ReportViewer control), no data shows up. Here's the related code:
    Code Block

            protected ReportViewer AttachToReportViewer(ReportViewer to)
            {

      // The ConfigureDVM() function inserts a dataset

      // into a DVM, sets up filters selected by the user,

      // and returns the DVM.

                DataViewManager myDataDVM = ConfigureDVM();

                // Configure report viewer
                to.ProcessingMode = ProcessingMode.Local;
                to.LocalReport.DisplayName = DISPLAY_NAME;
                to.LocalReport.ReportPath = PATH_TO_REPORT;

                // Connect DVM to report viewer.
                to.LocalReport.DataSources.Clear();
                foreach (ReportDataSource source in GetDataSources(myDataDVM))
                    to.LocalReport.DataSources.Add(source);

                to.RefreshReport();

                return to;
            }

            protected List<ReportDataSource> GetDataSources(DataViewManager myDataDVM)
            {

           List<ReportDataSource> reportSourceList = new
     List<ReportDataSource>();

                ReportDataSource rds = new ReportDataSource();
                rds.Name = "SampleData_Book";
                rds.Value = new BindingSource(myDataDVM, "Book");


                reportSourceList.Add(rds);

                return reportSourceList;
            }


    From the documentation I have read, this approach should work. I've traced the code up until the section highlighted in green, which is my best guess of where the error is occuring.

    Thanks for the help!

    EDIT: I managed to get the report to populate when I bind to a DataSet instead of a DataViewManager in GetDataSources. As before, the relevant line is highlighted in green:

    Code Block

            protected List<ReportDataSource> GetDataSources(DataViewManager myDataDVM)
            {

           List<ReportDataSource> reportSourceList = new
     List<ReportDataSource>();

                ReportDataSource rds = new ReportDataSource();
                rds.Name = "SampleData_Book";
                rds.Value = new BindingSource(myData, "Book");


                reportSourceList.Add(rds);

                return reportSourceList;

            }


    The report refuses to bind properly to the default view manager as well (in this case, replace "myData" with "myData.DefaultViewManager"). Does anyone know why this is?
    Friday, October 12, 2007 6:52 PM

All replies

  • Do you have the report viewer in a control? Or on a form?

     

    If the viewer is on a control, you have to add the method MyReportViewer.RefreshReport. When the viewer is on a form, this is inserted automatically.

     

    Hope this help,

    Ryan S. Thiele

    Friday, November 9, 2007 7:50 PM