Free - Dynamic Data Grouping using MS Reporting Services
Free - Dynamic Data Grouping using MS Reporting Services

Image: 1.0

Introduction

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.

Image: 1.0

Introduction

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.

Three button technique

To make life little more interesting, I added three extra buttons: Orders by Customer, Orders by City and Orders by Country to user interface. These three extra buttons on the user interface do not have any built in magic; they are just helping me demonstrate the technique.  So, without further ado:

Image: 1.1

Remember the game "spot the difference" from your childhood memories?  May I ask you to play the same game with Image 1.0 and 1.1?  Sure, they look different; the first image has a title called "Orders List" and the second image has "Orders by Customer", and so on…

If we pay a close attention then technically the difference is really the output format, the underlying data is same (orders information).  By this time, I am sure most of you probably understand my technique and how it will help you generate multiple outputs using dynamic controls to generate reports.

Image: 1.2

Image: 1.3

Asif Sayed

I started to code in 1990 using C and GW basic, then moved to 4GL world with DBIII, Clipper and FoxPro etc. and continued till I found and hooked to MS goody bag Visual Basic. For last four years, I am working extensively on .NET technologies and scripting both VB.NET and C#. My ideal choice of database is SQL Server; however, I do interact with Oracle when required. I have worked on all sort of Business applications, but my ideal project would be anything which has some Financial part associated with it, I wish I can put a Balance-sheet report in all the project I do… I also teach .NET related technologies as part-time faculty with local community college and try to help share my knowledge with others.

See All Postings From Asif Sayed >>

Place your review about Free - Dynamic Data Grouping using MS Reporting Services




You must me logged in to write a review
Reviews

Be the first to place a review