I still remember it was a neatly done report that got me my first pay raise. Ever since, I am very passionate about report writing (every one likes a pay raise right?). In this article, I will guide you through step by step on how to create a simple report using MS Reporting Services 2005; and host it with a Smart Client application.
So, are you ready to get your pay raise? Why not! Who knows, your neatly done report can just do that.
Prior to this article, I wrote three others, which were addressing different issues related to the reporting services. However, all of them were targeted towards the intermediate-advance level audience. From all the feedback I received, one was common, quite a few of you asked for an article which will be specially geared towards the novice-beginner level.
I assume the reader has a basic understanding of Visual Studio 2005 IDE and is comfortable with writing code using C#. You don’t have to know MS Reporting Services to understand this article; although, any pervious experience with writing a report would help.
Although, I am calling this article 101, my intention is to adopt the applied approach rather then discussing each and every topic associated with reporting services. I am touching the most common aspects of report design and I use the most common controls. I would strongly encourage you to go through the MSDN documentation for more detailed information.
We hear this all the time, “Two birds with one stone.” What if I say, “Four birds with one stone”? I am sure four sound much better then two. So, what are my four birds and one stone?
My four birds are four distinct different outputs generated using source NorthWind->Orders (SQL Server 2000) and my stone is single physical Ms Reporting Services .rdlc file, which I am using as template to produce different outputs. This particular figure of speech is perfectly applicable to the technique, which I am going to share with you.
The application of this technique is not something new; we all have done same or similar while dealing with reporting of data. What is new here is the approach, which I can call to reuse of report (as we commonly reuse the code).
Let us discuss a practical scenario here. If I ask you, what kind of output you see in (image 1.0); you would probably say a simple report listing orders information. Well, you guessed it right. What will you do if the end-users want same report using data grouped by CustomerID(image 1.1)? In most cases, you might end up writing a new report. In this article, I will demonstrate how to reuse the report to produce the demanded output without the need of writing a new report.
I assume the reader of this article is comfortable using Visual Studio 2005, C#, Sql Server 2000 and Windows Forms. Basic understanding of how report designer works is helpful to work with attached code.
I will start with a question here. How many of you had chance to interact with Employee table from sample database Northwind? There you go… I can imagine countless hands in air, and why not it is one of the standard databases comes with both Access and SQL server. All right, are we going to discuses Northwind database here? NO. Is Employee table is something special? I would say YES to this. Why special? Well, if you pay a close attention, it is just like any other standard table, however, two fields from the table, “EmployeeID” and “ReportsTo” are related to each other in an interesting way! Yes, you got it right; I am talking about Hierarchical relationship which we also call commonly as Recursive data. I am trying to shade some light on reporting of data which is recursive in nature.