Windows Reporting Services

I’m working on a project at the moment where we need to display a number of reports. The reports themselves are dished up via SQL Reporting Services. Since the application is a Windows Forms application we really wanted to keep the users in the application instead of popping browsers all over the place.

Our first thought was to embed IE inside the Windows Forms application which worked quite well, except the user experience wasn’t quite right for us. You see the problem was that if the user wanted to print out the report they could either use IE – which resulted in some ugly headers and footers on the page which looked less than professional, or the user selecting export to PDF and spinning off another window (why bother embedding if you are going to do that).

The solution was to initiate the download of the PDF directly from the Windows Forms application and embed Adobe Acrobat inside our application – this had several neat benefits – first we keep our in-application experience, and second, we get a whole series of tool-bars for free which allow things like searching, printing, saving and e-mail the document – as well as the typical zoom type functionality.

All in all a fairly good solution, although I don’t think this approach is unique by any stretch of the imagination. Here is some sample code which shows a reasonably nice streaming effect combined with a transition to the display of the document.

The reason I prefer this over something like Crystal is that it helps maintain the clear seperation between the client and server where the server is autonomous and completely abstracts the database.

22 thoughts on “Windows Reporting Services

  1. Chris O'Connor

    To do a DYNAMIC report – ie. using screen-entered/selected params – you can call the Reporting Services “Web Service” directly…

    And – use the “Render” method to return a byte-stream – which is then re-assembled as a PDF.

    Save it to the user’s hard drive – and navigate to it from within the application (as described above)…

    (Rather than calling a to a PDF file sitting on the web-server)

    This way – you can dynamically call a SQL Reporting Services “report” – with params from a WinForm – and have it shown INSIDE the application…

    Very Cool…

    (Email me if you would like some sample code)…

    Cheers,

    Chris O’Connor

  2. Mitch Denny

    Hi Chris, thats a good idea using the web-service interface. The thing with web-services is that it is hard to determine what is happening during the call.

    In my TechEd session I spoke about a few techniques you can use to provide feedback to the user while things are streaming back. Turning the progress-bar into a marquee-bar in Windows Forms is a good approach.

    The source code is at:

    http://notgartner.com/Downloads/SMT415.zip

  3. HyperX.

    Chris,

    Can you please send me the sample solution that you have???

    I have to do that exact thing like passing parameters via windows forms and generating dynamic reports.

    Thanks!!!

    HyperX.

  4. hyper_x_43@yahoo.com

    Chris,

    Sorry, forgot to mention my email addy…

    Thanks again for the help!

    HyperX

  5. AJPB

    In order to save time and effort, I would like to know if is possible to set different Stores Procedures to a report, and dynamically change the report’s layout and design based on the store procedure selected to work with.

    I need to generate a report that uses 4 different Store Procedures. The issue here is: I need to inidicate the report which SP to use in order to display the appropiate fields.

    Does someone out there knows how to create a dynamic report that can change based on a selected SP to work with?…If yes, how you did it?…

    Please, copy any responses to aplaz@yahoo.com

    Thanks in advance,

    AJPB

  6. Mitch Denny

    Hi there,

    I’d be more inclined to key on the report URL rather than the stored procedure name. You’d essentially have to regenerate the report using reporting services API’s from scratch which would just not be productive.

    Why not just have multiple reports . . . ?

  7. Michael Morisoli

    Has anybody figured out how to print a RS report directly from a WinForm app without the user being required to view it.

    I want to have a form that collects params, then calls the report but instead of displaying it, I want to print it directly to a printer installed on the clients workstation.

    This single aspect is killing me, any help is welcome.

    Thanks, Mike

    michael@vieon.net

  8. Mitch Denny

    In the approach that I take above I guess you could make the ActiveX control invisible on the screen and then call the print method (if there is one).

  9. Michael Morisoli

    Mitch, I have read a few threads about this and from what I understand the ActiveX control is only available to IE so you would have to use jscript or vbscript to trigger the print from within IE.

    I really don’t want to call IE to do the printing.

    There has to be a way where you can capture the byte stream from RS and then render it properly and print it.

    *sniff*

    Mike

  10. Mitch Denny

    Hi Mike,

    Download the code from the post above – it shows how you can embed the ActiveX control directly into the Windows Forms application.

    It then uses standard COM interop to find the methods that the ActiveX control exposes so that you can call them directly from VB.NET or C# code.

  11. Vijay

    Hi,

    I too have similar requirement. I want to invoke SSRS report print event from javascript or vb script.
    Can you please help me out.

    Thank,
    Vijay

  12. Mitch Denny Post author

    Hi Vijay,

    Unfortunately I can’t fix the link (the code was lost in a migration). However, if you want to invoke some JavaScript from a Windows application you can actually do it by getting a handle to the HTMLDocument instance that the WebBrowser control exposes.

    You can then execute arbitrary JavaScript inside the context of the browser. In fact, you can actually use reflection to get MethodInfo objects for these as well which can be useful in some instances.

  13. Nader Harb

    I created a report based on reporting services 2005 to print on a Label 2 in X 1 in. when i call the report it doesnt take the printer settings and It takes with landscape orientation and 1X2. There is any way to take the printer default setting.

    I have to deliver the project in 3 days.

    Best Regards,
    Nader Harb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s