Click here to Skip to main content
13,351,050 members (25,471 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 4 Aug 2010

Crystal Reports with Dynamic Number of Columns with Typed Dataset

, 4 Aug 2010
Rate this:
Please Sign up or sign in to vote.
Creating Crystal reports with dynamic number of Columns with Typed dataset with SQL Server 2005


While we were developing a trading application, I was asked for a Crystal report, which has a dynamic number of columns. There are factories having a number of distribution centers from 1 to 6. I needed to develop a report which would have dynamic columns so that we could display quantity in dynamic columns and also remaining quantity in the last column.


There is very little information available on the web for dynamic columns for Crystal reports. So I decided to write an article so that users could easily develop Crystal reports with number of columns.

In this article, I just show how we can create dynamic Crystal reports, what we use in this article are typed dataset, Crystal report and a SQL server stored procedure that returns dynamic number of columns which we show in our Crystal report.

So first, we create a typed dataset like this:


Here, we create some columns with name col1, col2, col3, which help us in creating dynamic report generation. Our stored procedure returns a dynamic number of columns with header col1, col2 and we bind that to this typed dataset. If there are any number of columns for any factory stored procedure, it returns columns as it is in typed dataset.

We have one more stored procedure that only returns Names of dynamic columns. We use this stored procedure to set parameters in report used as headers of columns.


We have some formatting in these headers, if no value comes in parameter, we don't format it and nothing is displayed, and if we get any value we change the background color of that parameter field.

if {?col1} <>'' then Color (192,192,192)

And in the detail section, we can just place the fields of our typed dataset.

When we run this report, it looks like:



  • 4th August, 2010: First revision of this article


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Abdul Quadir Saifee
Software Developer Caresoftinc
India India
Presently I am working as a software developer at CaresoftInc for the last 2.5 years. During these years I have acquired a very good knowledge of Web technologies (, ,C#.Net, VB.Net,OOPS, java-script, Ajax, SQl Server 2005,Crystal Report XI).

My responsibility includes develop modules and logic's for the application.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 3 Pin
Deepak Joy Jose17-Aug-12 1:23
memberDeepak Joy Jose17-Aug-12 1:23 
GeneralMy vote of 3 Pin
sathya150819-Jul-12 2:32
membersathya150819-Jul-12 2:32 
not clear in crystal report....
QuestionThe best solution Pin
gjoshi1111-May-12 6:19
membergjoshi1111-May-12 6:19 
GeneralMy vote of 5 Pin
quadirsaifee20-Sep-10 8:32
memberquadirsaifee20-Sep-10 8:32 
GeneralCrosstab Pin
Rogerio_Conio4-Aug-10 12:14
memberRogerio_Conio4-Aug-10 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 4 Aug 2010
Article Copyright 2010 by Abdul Quadir Saifee
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid