none
Discover the datasets required by an rdlc report? RRS feed

  • Question

  • Hi,

    I'm trying to develop a generic "report utility" in my application. My idea is that the application will look in a database table to find the list of available reports, (implemented as rdlc files for local execution) and present that list in a drop-drown menu for the user to choose from. The application will have direct file access to the rdlc files. When the user selects one of the reports from the list, I need to open that report in a ReportViewer control that is essentially static in the form. However, I'm unsure how to dynamically bind the report to its underlying data set when a report is chosen. It seems to me that I need some way to extract the list of data sets/tables required by a particular rdlc report so that I can then go and instatiate the proper datasets for that report and populate them with tableadapters. Does this approach make sense? Is there a way to get a list of required datasets for an rdlc without actually parsing the XML yourself?

    Here are some other facts about my project that might be interesting/useful:
      - I'm planning to use the Entity Framework for business object layer, but have been planning that my reports will use data sets rather than objects just because I think the relational model is more appropriate for report writing.
      - I'm trying to avoid using strongly typed data sets for my reports due to the fact that my reports span a couple hundred tables, resulting in a lot of code bloat if they are all strongly typed. Also because of this, I don't want to instantiate dataset that spans my 200+ tables. I just want the ones necessary for each report to be instantiated. I'm hoping to be able to dynamically find out what datasets I need to instantiate from the RDLC file, then create/populate them with the aide of a deserialized data set XSD. Is this a reasonable approach?

    I apologize if my terminology isn't quite right or this just generally seems insane. I'm new to .NET development and am swimming through the different technologies. I swear I have a degree ;)

    Thanks,
    Kyle

    Thursday, June 4, 2009 9:17 PM

Answers

  • The list of datasets required by a local mode report is available from ReportViewer.LocalReport.GetDataSourceNames().  But because local mode does not use the query or connection information associated with a data set or data source, that information is not exposed through the ReportViewer API, even if it is in the RDLC file.  If you are able to map the data set names to well known connection strings and queries, the GetDataSourceNames API should be sufficient for your needs.  If not, the only way to extract that information is by parsing the RDLC file yourself.
    • Marked as answer by kylejmcintyre Thursday, June 18, 2009 5:30 PM
    Thursday, June 18, 2009 5:19 PM
    Moderator

All replies

  • The list of datasets required by a local mode report is available from ReportViewer.LocalReport.GetDataSourceNames().  But because local mode does not use the query or connection information associated with a data set or data source, that information is not exposed through the ReportViewer API, even if it is in the RDLC file.  If you are able to map the data set names to well known connection strings and queries, the GetDataSourceNames API should be sufficient for your needs.  If not, the only way to extract that information is by parsing the RDLC file yourself.
    • Marked as answer by kylejmcintyre Thursday, June 18, 2009 5:30 PM
    Thursday, June 18, 2009 5:19 PM
    Moderator
  • Thanks, that's what I was looking for. I had given up on this post ;)
    Thursday, June 18, 2009 5:30 PM