Labels

Thursday, January 11, 2007

Programming Tips

String.Format("{0:F2}", 789.123456)
New Object() {source, eventType.ToString}

ASP.NET Animated Gifs and Long Running Processes

System.Reflection.Assembly.GetExecutingAssembly().Location()

Extension methods

    public static class MyExtensions
    {
        public static int WordCount(this String str)
        {
            return str.Split(new char[] { ' ', '.', '?' },
                             StringSplitOptions.RemoveEmptyEntries).Length;
        }
    }  

Crystal Reports VS Reporting service

Crystal Reports "Sucks''
Well, I'm in the “Crystal Sucks” crowd. It didn't used to suck but with the advent of .NET, things just went downhill. Actually, it did kind of suck even back in the day, there just weren't as many viable alternatives. IMHO, Crystal is so poor in just about every regard that it's not worth using. I'm increasingly becoming a fan of SQL Server Reporting Services and this book has done WONDERS for me in getting through the learning curve. I can't think of one single area Crystal makes a better choice than Reporting Services or ActiveReports or just about any other area. Deployment sucks, they run slow, they're painfully fragile, licensing takes 4 PhDs and JD to figure out. Then again, Report Writing in general is like total Sh1t duty in most cases. Glad I'm not just entering the business and getting stuck writing reports - it's definitely a boring endeavor and Crystal makes it even moreso.
As far as Crystal though - it's a good tool for doing stuff in house and getting info in a quck and dirty manner. The later versions are nightmares though and in every intelligible way that I can see, a move backwards. I mean, sure, you can claim you have "Strongly Typed Reports" but big deal when deployment is so sorry. The comment about it being fragile is probably the best way to phrase the current state of it -it takes NOTHING to break it. Look at the number of newsgroup posts on the 'Can't find Keycode32.dll' errors - I actually wrote an article on this because a lot of the documentation is wrong or points you to a different problem. And in the new VS.NET version - you don't even have design time preview, you have to add a viewew to your project, set the reportsource and open the form after the program is compiled.
Have you used the newer versions like the one that comes w/ .NET? Uhhhh. Crystal USED to be a cool product, but it went backward. Strongly Typed Reports are the upside, but you pay for that 'wonderful' benefit by losing preview ability and an IDE that you can navigate around easily. And deployment - uhhhhhh - it's like getting kicked right in the nuts every time you need to change the database or a table or whatever.Just got into SSRS myself. Bought the apress book and the wrox book. the apress book is good for our data analyst...the wrox book good for the coders. i hate crystal with a passion. I have written my own report engine on more than one occasion to avoid crystal. plus, could crystal be more freakin' expensive for the enterprise version? it makes pretty pictures! and the new one with .net...could they be more intent on not having you do anything outside of the GUI designer? The designer that sucks...

Crystal Reports clearly does "suck". There are countless features that are so mundane, common, and seemingly simple that it amazes me how futile the effort has been to implement them. Let me list just a few on my list:
* Sub-reports Within Sub-reports - This needs no further explanation. Without this ability a reporting engine is worthless.
* "Buggy" Can Grow Property - This needs to work better with fields below it. What is the point of allowing a field to grow if it is only going to grow all over the rest of your report? Not to mention that doesn't work well with subreports (seeing a trend yet?)
* Limited Support for Adhoc Queries - Ever try to use a custom SQL statement as your data source? Doesn't work so well. It seems Crystal would prefer that you create countless views on your server to accomplish even the simplest reporting tasks.
* Calculations On-the-Fly - Why can't I take a field from my data source and modify its appearance on the report? As an example, if I have a floating-point number that is returned from my query I would like to be able to format the number to the correct number of decimal places and add the '' on the report rather than in the query.

I've just all of the comments about Crystal Reports product above and, as someone who works with the product extensively I can see that people above clearly have not taking any training before using the product so that they could understand how to use it effectively. The wizards are used typically to create the report - you wouldn't use it to edit the report however, you would just, for example, add another column by simply dragging the database field into the details section. As for subreport within subreports - recursively allowing unlimited numbers of subreports is a sure way to cause problems - not to mention making your report impossible to follow by anyone other than the person who created it. I've never yet seen an instance where this was a must. If you are having troubles, stop beating your head against your monitor and get in touch with the Customer Support reps at Business Objects, they are well trained and capable of helping you either through their Answers-by-Email system or, for a small cost, over the phone. But the most important thing to do is to get some training with the product first. It will save you countless hours of hair-pulling.

Wednesday, January 10, 2007

Crystal Reports for Visual Studio


Articles on using Crystal Reports in Visual Studio 2005

How to Deploy Crystal Report?

Unbound Currency Fields and Regional Settings

Some of the unbound fields in Crystal Reports are affected by the operating system's default settings. For example on a machine with a US locale the date will be of the format mm/dd/yyyy. For dates, this can be easily overridden by setting the DateWindowsDefaultType property to crNotUsingWindowsDefaults. Unfortunately such an option does not exist for currency fields. Setting the property CurrencySymbol is completely ignored and there is nothing you can do about it. The easiest workaround is to use a number field rather than a currency one and then use the CurrencySymbol property.

Deployment
First of all, ensure that your development machines have the latest service pack and critical updates. Once you have done that, download the latest merge modules.
Just to be safe, when you create a new setup project exclude Crystal_Managed2003.sms, which is automatically added by Visual Studio under Detected Dependencies. Then, manually add all the merge modules (yes all, even if you don't think you need them, you probably do; more information on this later on) that you downloaded as well as the following two merge modules that are not included in the download, but are already on your machine.
VC_User_CRT71_RTL_X86_---.msmVC_User_STL71_RTL X86 ---.msm
If you have performed all these steps correctly you should have the following 6 merge modules added to the setup project.
Crystal_Database_Access2003.msm (latest version included in the download)Crystal_Database_Access2003_enu.msm (latest version included in the download)Crystal_Managed2003.msm (latest version included in the download)Crystal_regwiz2003.msm (latest version included in the download)VC_User_CRT71_RTL_X86_---.msm (already on your machine)VC_User_STL71_RTL X86 ---.msm (already on your machine)
Now select Crystal_regwiz2003.msm in Solution Explorer and view its properties. Find the (MergeModulePropeties) property and expand it. A property called License Key should have appeared. In this property enter the key that you will find in the About dialog under the Help menu in Visual Studio. The key will be 19 characters long and probably look something like AAP50-GS99999-U9999RN. That's it, you can now add the project outputs and contents of your projects to the installer and build it.
You might think that some of the merge modules mentioned earlier do not really apply to your reports. The names of the merge modules are deceiving. Crystal_Managed2003.msm is always required no matter how your reports are built and so is Crystal_regwiz2003.msm because that is the only way to register Crystal Reports on the deployment machine. Crystal_DatabaseAccess2003.msm and Crystal_Database_Access2003_enu.sms apart from drivers for database connectivity they also contain the dlls that allow reports to be exported to other formats such as PDFs and Word documents. If your reports access any ADO.NET datasets then VC_User_CRT71_RTL_X86_---.msm and VC_User_STL71_RTL X86 ---.msm are also required. For (a bit) more information you can read this document.


Exception Details: CrystalDecisions.CrystalReports.Engine.InternalExc eption: Cannot find KeycodeV2.dll, or invalid keycode.

The reason you are getting this error is because the machine that you are trying to run your application on does not contain the drivers Crystal Report needs to run. Here is your solution:Finding Out What the Crystal Report Distribution Key is on VS.NET 2003:1- Open VS.NET 20032- Click on Help Menu Option3- Choose "About Microsoft Development Environment"4- Look under Crystal Reports for Visual Studio .NET, you will see a 19 character number, which is the Distribution Key Code:Example: AAA00-BB00000-C0000DDProducing the Deployment Project:Open Solution Explorer, right click on the “Solution Name” at the top and Add a New Project. On the window that appears, move to Setup and Deployment Projects. Click on Setup Project (not the wizard), put a name for your deployment project (make a note of the location where the folder that the deployment project will be created in) and then click OK. A File System dialog will appear – solution explorer should be displayed on the left of screen. Within solution explorer – right click over your deployment project and select Add – Project Output. Another window will appear – select Primary Output (make sure configuration is showing Active) and click OK. This will result in the detected dependencies being updated & a primary output icon appearing in the deployment project. Right click on the deployment project name again and Add – Merge Modules. Add the following modules.Crystal_Database_Access2003.msmCrystal_Database_Access2003_enu.msmCrystal_Managed2003.msmCrystal_regwiz2003.msmVC_User_CRT71_RTL_X86_---.msmVC_User_STL71_RTL_X86_---.msmThese were the appropriate modules for my application given that I am using VS 2003. Yours may be slightly different. Right click on Crystal_regwiz2003.msm and go to its properties. Enlarge the MergeModuleProperties tree and enter the product licence key.Go onto Build – Configuration Manager . Check that the Project & Deployment Project which appear are set to “Release” and the Build check box for each is checked. Build the Project. If all is well the build should show no errors.If this has gone according to plan you should now have (in the folder specified in the “location” window given when you added your deployment project) a debug and release folder. The release folder will contain:- setup (application)- setup (config file)- an installer packageThe release folder is all that is needed to deploy the application on another machine.Note:

The original source of this tutorial was (http://www.vbcity.com/forums/topic.asp?tid=67989).
DigiOz Multimediahttp://www.digioz.com/