adsense

Friday, August 31, 2012

asp.net crystal reports issues

If you are going to do reporting with crystal reports  you will face some problems in configuring it.  Follow these steps to minimize the fuss. It took me almost a day to figure these out ...!!

1) Create a Asp.Net Reports website.
2) Add other configuration settings to web.config file. (i.e connection strings, httpmodules...etc)
3) If you are getting the error "Sys.Application' is null or not an object",  Edit theC:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETClientFiles\crystalreportviewers14\js\crviewer\crv.js  as follows
 insted of
if(typeof(Sys)!=='undefined') {

    Sys.Application.notifyScriptLoaded();
}
use
if(typeof(Sys) !== 'undefined' && typeof(Sys.Application) !== 'undefined') {
Sys.Application.notifyScriptLoaded();
}


Note: You can download Crystal Reports runtime for  Visual Studio 2010 from

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/22083

http://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp

Edit:
 Crystal reports seems to have some incompatibilities with Microsoft Ajax framework. In fact if you put a crystal report viewer inside an update panel it will prompt you various JavaScript errors at run time. So you have find other ways to overcome this such as using third party tools. I am contended with Microsoft Reports which very well suited for my requirements...!!!

Edit
check following link for resolving CR issues after deployment in IIS
http://social.msdn.microsoft.com/Forums/en-CA/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203

You might also give a try by referring following links which might aid in resolving all those javascript  and image missing errors I have mentioned before. I did not try these and if anybody got luck with this pls let me know..!!

http://forums.asp.net/t/1693771.aspx/1
http://forums.asp.net/t/1226411.aspx/1
http://social.msdn.microsoft.com/Forums/en-CA/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203

Update
It seems to be a common error "Failed to export using the options you specified. Please check your options and try again." when exporting Crystal reports. This happens when the page is posted back and data source is unavailable to the CR viewer. As a workaround follow the instructions given by Mogulla in the following forum.

http://social.microsoft.com/Forums/en/Offtopic/thread/f9ae2910-463e-40f5-92ac-9c29c03c31c3

In addition try following method for printing crystal reports using JavaScript.

http://aspalliance.com/509_Automatically_Printing_Crystal_Reports_in_ASPNET.3

Note: You might have to install CR service packs (3 as most have recommended) before trying these. It seems there are issues with CR SP 4 for VS 2010. Following link provides the available SP s for CR 2010.


http://scn.sap.com/docs/DOC-7824


With a lot of struggle I was finally able to make use of print and export buttons in Crystal reports viewer. Unfortunately you will have to remove any of the update panels used in the page, which indiactes that page refresh will have to be tolerated.The following link will give you some tips on achieving this.
http://www.codeproject.com/Questions/239062/Problem-in-Crystal-Report-toolbar-ASP-Net

cheers

Happy coding.

No comments:

Post a Comment