Ok, after surviving 5 days without electricity I guess I am ready for new post. We had great storm last week and it caused state wide power outages. Some cities still don’t have electricity yet !! Anyways, this post is about creating basic report using Crystal Reports in ASP.NET
I think Crystal Report has been part of Visual Studio from beginning of time. And it has been very popular reporting tool due to its simplicity and flexibility (compared to SSRS). I personally think that it is more easy to work with compared to SSRS but it still misses features like report management and control. So I like to work with both of them .
With VS 2010, MSFT has changed it strategy. They still support CR, but they also has begun to promote SSRS. When you install VS 2010, it doesn’t install CR runtime components, so you will need to download it from SAP website (both Runtime and Controls).
Ok, so I begin with creating empty website project for ASP.NET. And then add web form using add new item. Then add report viewer control to page. Next step is strange but required in order to avoid error. Once control is added to page, close the project and open it again. With surprise you will be presented with upgrade wizard for your crystal report to upgrade to newer version !! If you look at CR, reference in page before upgrade is,
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
And after upgrade it will be changed to,
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
It looks like some sort of bug of VS 2010, due to which when we add control for CR it adds older assembly reference not the newer one !!
Next step is to add report data source, for this I selected new source and also new report. After this step, it will open up report designing wizard for CR. For simplicity of demo, I have chosen to use “Wizard” for new report. Report designing wizard steps are pretty much self-explanatory.
Once done configuration of report hit F5 and cross your fingers. If everything is done properly you should see report in your web page.
Project I used for this post available for download here.
It’s Just a Thought …