Adding New Fields To Stored Procedure And Updating It In Crystal Reports
This is another rant against Crystal Reports: I just noticed that three of my colleagues have been living a lie when it comes to Crystal Reports.
I don’t blame them. It’s simply because Crystal Reports is NOT AT ALL intuitive.
What does “Verify Database" mean to someone who is new to Crystal Reports? And what is a right-click + Refresh supposed to do? You would think you knew what these meant until you tried them for yourself.
hmmm, yeah, that’s right.
Consider the following scenario:
You have a crystal report .rpt file that’s mapped to a Stored Procedure. You are living happily ever after until someone from the top tells you that they want one more column in the Crystal Report.
Piece’a cake. So that you fire up SQL Server, open the Stored Procedure and add one more column that would be returned in the Stored Procedure’s SELECT statement.
DB part over. Now the Crystal Report part.
You fire up Crystal Reports and open your .rpt file so you can add the new column after picking it up from the Stored Procedure.
Okay, now hold it.
There are two possibilities here:
1. Either you know how to add a new column from your updated Stored Procedure the right way…
2. Or you don’t and do it the totally wrong way.
If #1, then this post isn’t for you. You know exactly what I’m talking about already because you’ve been there once upon your once-upon-a-time-miserable-Crystal-Report life and got over the whole sordid details of this drama.
If #2, you’re probably one of those guys who disconnects the database connection from the .rpt file, reconnects them and after the hassle, loose ALL your data fields, formulas, group sections and anything else that might have remotely touch your data on your Crystal Reports canvas.
That’s because if you right click on the command node within the fields tab to hit refresh, you never get the Stored Procedure to reflect the new field even if you do that a zillion times. You are so used to this that you’ve lived with the lie that every time you need to add a new column, you have to loose ALL your data fields, formulas, groupings etc on the .rpt file that you manually add them again onto the Crystal Report Canvas.
A quick search reveals that this is a common problem faced by a lot of developers and not everyone is sure if there is a straight forward way to get around it.
Fortunately there is. And it’s pretty straight forward. Just that it’s not presented in a straight forward manner…
Adding New Field To Stored Procedure And Getting It Reflected In Crystal Reports
The real way to do it is the most non-intuitive way. It’s actually pretty simple
1. Open to the Database pull down menu
2. Click Verify Database and enter your DB credentials
3. Crystal Reports will prompt you for the stored procedure parameters. Enter them correctly. Usually at this point, users simply ignore due to the hastle of entering in all the parameter values. But you must do this to re-register your Stored Procedure.
4. Once you’ve done the above step, Crystal Reports will notice that there is a change and prompt you for proceeding with the update. Click OK and you’re set to go.
The reason this WHOLE PROCESS is actually a hassle in figuring out is because VERIFY DATABASE in NO WAY tells the user that it will update or refresh your Stored Procedure or data source. When a normal user sees that, the first thought that crosses his/her mind is that this is a place to enter Database credentials which is actually right. Further, there should be NO REASON whatsoever that developers need to enter values for the Stored Procedure parameters to have it Crystal Report refresh it. Some stupid button should be there somewhere where you can just hit “refresh" and then voila, the SP is refreshed instantly. Unfortunately no magic button like that exists though it should have been there long back considering that we’re in Crystal Reports ver 11!
But what makes this a pain is that most first-time users are unaware (and for good reason) that Verify Database does MORE than just Verify Database
For years, my colleagues believed that Verify Database was just a way to confirm Database credentials. They had given up a sane way of updating data fields onto the Crystal Reports canvas.
It’s because of reasons like this that I’m not at a big fan of Crystal Reports. Yet I use it simply because once you know the quirks, it’s piece’a cake. And then it really does makes the job of getting those much needed reports for senior management and users possible in all sorts of formats with a relatively simple design effort. But till you cross that “first stage", you run the risk of running into hurdle after hurdle for nitty-gritty stuff.
It gets really irritating when you find important aspects to the tools you use very much absent. I explained my last wonderful experience long back over here. I’ve seen many developers go through the same cycle and come out with a huge sense of achievement. But the fact is that no such achievement was made in the first place. The only “achievement" achieved was a big waste of time for something small that should have otherwise been pretty intuitive.
I think it’s about time that Business Objects takes a look at the usability and discoverability aspects of different features within Crystal Reports so that developers can speed up with productivity.
Good night and Happy Programming!