Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
Add to Technorati Favorites


ASP Insider Follow Me On Twitter
Data Binding and the Crystal Report Viewer

I think it is nice that Microsoft includes a FREE Crystal Report viewer with every copy of Visual Studio.  I had never bothered to use Crystal when I first looked that the licensing prices back in 2001, when they first included Crystal in Visual Studio 2001 or 2000 or what ever the first .NET visual studio was.  This week I had my first project and first exposure to using Crystal Reports, and it has not been a good experience so far.

First, let me say I am thankful that I did not have to design the reports, Jennifer was responsible for that.  She has many years of experience with Crystal, using SQL Server for the backend, VB 6 as the development platform and desktop applications.  So the first this is great, SQL Server, the next two not so helpful.  Jennifer is a great programmer and I can not stress that enough, but she has next to zero experience developing web applications so this experience was totally new to her too.

Anyway, a few weeks ago Jennifer wanted to make sure I could display a Crystal Report in ASP.NET, she sent me a simple hello world type of report that just pulled some basic records from a table and echoed them out to us.  Everything worked fine, I had just created a simple hello world type page to display it.  So this week we got to the real world, and it was nasty.

I think it is a pretty universal Cardinal Rule in the ASP.NET world to utilize the IsPostBack property in every Page_Load event handler.  We do this to avoid round trips to the database, reprocessing business logic that does not need to be processed again and again after the page is loaded.  Evidently the developers at Business Objects have not gotten this memo.

When I first loaded our production report, I got the data.  But then we tried to click the print icon and got nothing.  So we tried some more things, including a new report.  Many times it would ask us to set the login information again.  For some strange reason it would not let me change the server from the UNC name to an IP address or real domain. 

So I began searching for Free Crystal Reports Tutorials and found that Eric Landes has quite a few articles and tutorials posted on his section of ASPAlliance.  I also found several references on the Business Objects site.  Not really knowing the vernacular of the Crystal world, some of the concepts are extremely foreign to me, so I have to try just about all of them.  Some tell us we need to physically bind the data to every table in the report (that seemed odd, since the report just displays data, but oh well).  Others explain different ways to set the connection, on and on.  There are a lot of ways to do the same exact thing in Crystal, but you know what I was still being prompted multiple times to provide login information.

Finally I thought I would try something, something so horribly wrong I shudder to post it here.  I put the databind code outside the IsPostBack check. (OK you can gasp in horror now, I did).  But to my surprise, it worked.  So this is my conclusion to the whole mess, since Microsoft is including the Crystal Report Viewer for ASP.NET with Visual Studio and obviously working with the marketing group at Business Objects, they should maybe spend some time on the other floor with the developers at Business Objects and explain to them how to write a basic data retrieving page in ASP.NET.

If you know any different please feel free to comment below and corrct me, but this is my conclusion from my observations.  Crystal Reports requires a complete data reload each and everytime you click an action button, like Print or page, etc on the report.  On top of that it requires a complete data reload for each and every table object in the report.  Even for a desktop application, this is a horrendous method of binding data to a control in any .NET application, web or smart client.

Finally, in my searches I found many, many people searching for this answer to their problems.  I saw many people posting their efforts including completly wiping out there system and reinstaling everything.  And this was just in the Business Objects supported forum.  The best solution anyone had was Business Object offering to answer the question for a mere $195.  Well I am answering it for free right here!

Posted: Sunday, January 15, 2006 8:27 AM

by Chris Love
Filed under:

Comments

raj said:

Sir, How to attached crystall report in vb 6. I am in new crystall. pls help me. by Raj
# April 15, 2008 7:48 AM

raj said:

how to attached crystall report in vb 6
# April 15, 2008 7:50 AM

Manoj said:

Chris, you saved my day. I was calling my Bind method in postback, but as you had pointed out, navigate button click in the report viewer was not yielding and report! Now I call the Bind method on both post back and on not postback, and all is well now. Thanks to you! Regards, Manoj
# August 26, 2008 9:38 AM

Vasanth said:

Hello!! On a button Click I display a Crystal report, if i click any of the Crystal reports Toolbar the report goes blank. Could you please help with an sample code.
# September 4, 2008 6:04 AM

dsafds said:

how to transfer from datagrid to crystal report.
# March 7, 2009 5:54 AM

Tess Martinez Rivas said:

Could you send me a code example, please? I'm not understanding correctly, and that solution doesn't work to me. Thanks a lot. Tess Martinez Spain
# June 22, 2009 10:38 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS