cancel
Showing results for 
Search instead for 
Did you mean: 

Update Crystal Report Field Property data source

williamm35
Discoverer
0 Kudos

We are moving to a new data source for our CR. We have several thousand reports that need to "repoint" to the new data source. Is there a way to update the individual field properties in a mass update approach, or does each report need to be completely rebuilt? 

View Entire Topic
DellSC
Active Contributor

You could write a program using either the .NET SDK or the Java SDK that would walk through your reports and do this.  There are a couple of things you need to be aware of when you do this:

1.  If you're joining tables in the Database Expert or using Commands and the table structures (table and field names and general data types) are the same, this is easy:  
- Load the report into a ReportDocument object.
- Change the Datasource.
- Call ReportDocument.VerifyDatabase() to update the field types to match the new database.
- Save the report.
NOTE:  You'll have to do this not only for the main report, but you'll also have to walk through the sections of the report to find any subreports - for each subreport, cast it as a ReportDocument and do the first three steps.  Wait to save the report until everything is updated.

2.  If the table and field names are different, things get more complicated.  You'll have to have a way to map the old tables/fields to the new ones if you're joining tables in the Database Expert.  If you're using Commands, it's probably easiest to do those manually.  You don't have to recreate the report from scratch.  Instead, you'll do this:
- Add the new connection to the report.
- Add a command with the updated query to the report.
- Update all of the formulas to use the fields from the new command instead of the fields from the old command.  This includes and formulas used in the Section Expert and the formula in the Select Expert.
- Replace each field (not formula) on the report with the corresponding field from the new command.  Before deleting the old field, right-click on it in the report, go to "Format Field..." and check to see whether there are any formulas used for suppression or formatting.  You'll need to replicate these formatting  formulas on the new fields.
- Delete the old command from the report.
- Save the report.  Close Crystal and then open the report again (this is the only way I know of to close the old connection...)
- Go to the Database Expert and delete the old connection from the report.
- Verify the database in the report - this will let you know whether you missed updating any formulas.  If anything comes up, fix it.
- Save the report and move on to the next.

-Dell