locked
Embedding custom String in Report and accessing it from external app RRS feed

  • Question

  • Hello,

    I'm searching a way to embed custom strings (not images!) in the rdlc file.

    I want to save in the rdlc file some values that I want to read from an external program (Windows Form or WebApp).

     

    Suppose I need to distribute a rdlc file with custom values like "Query".

    The webapp loads the rdlc report, reads the "Query" value, executes it, retrieves the data in a DataSet and passes the DataTable to the report using the ReportDataSource object.

    It allows to distribute reports without changing the code that executes the reports, the query is embedded in the rdlc file.

     

    I've tried to use the Parameters using the "Default Values" but I can't access the default value.

     

    Can someone help me?

     

     

    thanks,

    Matteo Conta

     

     

    Wednesday, October 31, 2007 3:41 PM

Answers

  • Thank for your reply, I'm looking for a way to embed custom data (parameters) into the rdlc file, imagine a way to insert data like Author, Department, Role.. whatever data I want to insert and read later from my application.

    I don't need to SET this data from my program, I only need to read it.

     

    I found that I can use values inserted into the report parameter ValidValues collection :

     

    string sMinimunRoleRequired = ReportViewer1.LocalReport.GetParameters()["sRole"].ValidValues[0].Value

     

    or

     

    string sMinimunRoleRequired = ReportViewer1.LocalReport.GetParameters()["sRole"].Values[0].Value

     

    I can access this information after I call the LocalReport.SetParameters, before the call to the ValidValues collection has zero elements.

     

    Is there a better solution?

     

     

     

     

     

     

     

     

     

    Monday, November 5, 2007 8:54 AM

All replies

  • If you generate the RDLC as part of a winforms LocalMode project and use the VS-generated strongly-typed data sets, the query strings are embedded in the RDLC (as part of the Dataset definition) for you.

     

    Is that what you're looking for...???

     

    Friday, November 2, 2007 10:31 PM
  • Thank for your reply, I'm looking for a way to embed custom data (parameters) into the rdlc file, imagine a way to insert data like Author, Department, Role.. whatever data I want to insert and read later from my application.

    I don't need to SET this data from my program, I only need to read it.

     

    I found that I can use values inserted into the report parameter ValidValues collection :

     

    string sMinimunRoleRequired = ReportViewer1.LocalReport.GetParameters()["sRole"].ValidValues[0].Value

     

    or

     

    string sMinimunRoleRequired = ReportViewer1.LocalReport.GetParameters()["sRole"].Values[0].Value

     

    I can access this information after I call the LocalReport.SetParameters, before the call to the ValidValues collection has zero elements.

     

    Is there a better solution?

     

     

     

     

     

     

     

     

     

    Monday, November 5, 2007 8:54 AM
  • >>imagine a way to insert data like Author, Department, Role.. whatever data I want to insert and read later from my application.

     

    Yes, there is a better solution.  Custom properties are supported on any element in the schema -- although to put them in through the Designer you are much more restrictive.

     

    I wrote a tool to do this, actually, soup to nuts. It's called RDLDocumenter.  It is based on the idea that RDLs ought to be able to encompass something like XMLDocs, so I wrote a schema extension called XMLRSDocs.

     

    You can read about the idea here  http://spacefold.com/lisa/post/Introducing-XMLRSDocs-and-RDLDocumenter.aspx and the tool and its docs are here http://spacefold.com/articles/XMLRSDocs.aspx .  In this screenshot from the docs, you can see the design-time tool at work, both annotating standard layout controls and adding custom properties at a global level. http://spacefold.com/articles/XMLRSDocs_images/Intro2.png

     

    This is a kind of large subject <g>.  We can take this off-line if you are interested.

     

    >L<

     

    ...

    Tuesday, November 6, 2007 3:30 PM
  • A little PS to Lance: RDLDocumenter lets you do that stuff.  You get to pick out what metadata you want to display from the RDL/RDLC -- custom properties, sql strings, whatever -- because (duh, this was such a head-slapping idea) RDLDocumenter pulls the metadata out as dataset-shaped data and therefore you can use REPORTS as well as other output types to display the results.

     

    Heck I'll quote from my own docs:

     

    RDLDocumenter "understands" SQL Server Reporting Services' XML report definition files. It extracts information from RDLs and RDLCs into a convenient XML data format, docRDL.xml, from which you can generate many different types of documentation.

    docRDL.xml is designed to be easy to load into a table or a DataTable member of a DataSet. That means you can, using a very natural and familiar mechanism, use this data as a datasource for one or more RDL or RDLCs, to provide documentation about your reports.

     

    Screenshot of docRDL.xml: http://spacefold.com/articles/XMLRSDocs_images/Intro1.png

     

    The test harness, naturally, comes with a couple of RDLCs which you can swap out and/or edit. See screenshot: http://spacefold.com/articles/XMLRSDocs_images/TestHarnessUI4.png

     

    This is a work in progress but a very full-featured concept.

     

    >L<

    Tuesday, November 6, 2007 3:52 PM
  • Hi, thank for your reply,

    I read your post and it seems interesting, one question: after I add metadata to my report is there a simple way to access it from external code (asp.net or win form..)?

    Do I use the XML parser, load the rdlc file and query the custom xml nodes addedd by the RDLDocumenter tool?

     

    Matteo

     

     

    Tuesday, November 6, 2007 5:04 PM
  • >>after I add metadata to my report is there a simple way to access it from external code

     

    Of course.  That's the whole head-slapping idea.  RDLDocumenter, the design-time tool, was sort of an afterthought to allow people to get the data *in* there as part of their design process.  It wasn't my original point at all.

     

    The original point was to *extract* the data cleanly into a form in which it *was* usable -- without necessarily having to load up the RDL as an XML document and parsing it.

     

    That's what XMLRSDocs is. It's a simple schema that is dataset-shaped.  It is the extracted data from the RDL in a more usable format.  The test harness form will load it to a SQL Server table for you, or just save it as XML files.  From either place you can load it to a dataset, it's exactly the right shape for that.

     

    The actual columns that I happen to use within my metadata docxml dataset might not be to your taste.  That's easy to change.

     

    The method I use to extract RDL-> RSDocs.xml is XSLT. That's easy to change also if you really hate it <g>.  But, even if you wanted to change the column/structure of the dataset that you're extracting, it doesn't make much change to the XSLT to do that.  (If you REALLY hate it, go ahead and parse instead <g>).

     

    The files I supply include a whole bunch of different ways for going through this process:

     

    * -- once again, there is a test harness form that performs all the extraction services so that you get the idea.

     

    * -- there are some scripts showing you how to do it in VBS and TSQL

     

    * -- my "production" process is actually an SSIS package.  This simplifies targeting a bunch of different output targets, which might include integration of the results into Sandcastle-produced documentation.  The idea here is that, from the docXML intermediate format or its SQL table-loaded equivalent, you could create XMLDocs-style class documentation as if each RDL was a class, and then your application would have integrated RDL docs in Sandcastle style along with your
    "normal" classes and other features.

     

    >L<

     

    Tuesday, November 6, 2007 5:15 PM