Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I point Crystal Reports at a new database

I have a Crystal Reports 2008 user that has over 100 custom developed reports. The reports all query Sql Server databases (SQL 2005).
This database server is getting replaced with a new system (running SQL 2008 R2) and the existing databases will be moved to the new server. The new database server will have a different name (which I can address via the Crystal Reports Connections), however, one of the applications is also being upgraded at the same time. The old database (DB_A) will be restored on the new server for historical reporting and a new database (DB_B) will be created. The new DB_B will have a very similar schema, so I would expect that most of the Crystal Reports should be able to run against the new DB_B with little or no modification other than pointing the report definition at the new DB_B.

Of course, the majority of my users custom developed reports query against DB_A.

My question is: How do I modify existing Crystal Reports files to point at the new database name (DB_B) instead of the old database (DB_A) ?

like image 220
JSR Avatar asked Nov 14 '11 21:11

JSR


2 Answers

Use the Database menu and "Set Datasource Location" menu option to change the name or location of each table in a report.

This works for changing the location of a database, changing to a new database, and changing the location or name of an individual table being used in your report.

To change the datasource connection, go the Database menu and click Set Datasource Location. enter image description here

  1. Change the Datasource Connection:
  2. From the Current Data Source list (the top box), click once on the datasource connection that you want to change.
  3. In the Replace with list (the bottom box), click once on the new datasource connection.
  4. Click Update.
  5. Change Individual Tables:
  6. From the Current Data Source list (the top box), expand the datasource connection that you want to change.
  7. Find the table for which you want to update the location or name.
  8. In the Replace with list (the bottom box), expand the new datasource connection.
  9. Find the new table you want to update to point to.
  10. Click Update.
  11. Note that if the table name has changed, the old table name will still appear in the Field Explorer even though it is now using the new table. (You can confirm this be looking at the Table Name of the table's properties in Current Data Source in Set Datasource Location. Screenshot http://i.imgur.com/gzGYVTZ.png) It's possible to rename the old table name to the new name from the context menu in Database Expert -> Selected Tables.
  12. Change Subreports:
  13. Repeat each of the above steps for any subreports you might have embedded in your report.
  14. Close the Set Datasource Location window.
  15. Any Commands or SQL Expressions:
  16. Go to the Database menu and click Database Expert.
  17. If the report designer used "Add Command" to write custom SQL it will be shown in the Selected Tables box on the right.
  18. Right click that command and choose "Edit Command".
  19. Check if that SQL is specifying a specific database. If so you might need to change it.
  20. Close the Database Expert window.
  21. In the Field Explorer pane on the right, right click any SQL Expressions.
  22. Check if the SQL Expressions are specifying a specific database. If so you might need to change it also.
  23. Save and close your Formula Editor window when you're done editing.

And try running the report again.

The key is to change the datasource connection first, then any tables you need to update, then the other stuff. The connection won't automatically change the tables underneath. Those tables are like goslings that've imprinted on the first large goose-like animal they see. They'll continue to bypass all reason and logic and go to where they've always gone unless you specifically manually change them.

To make it more convenient, here's a tip: You can "Show SQL Query" in the Database menu, and you'll see table names qualified with the database (like "Sales"."dbo"."Customers") for any tables that go straight to a specific database. That might make the hunting easier if you have a lot of stuff going on. When I tackled this problem I had to change each and every table to point to the new table in the new database.

like image 199
Todd Walton Avatar answered Sep 18 '22 03:09

Todd Walton


Choose Database | Set Datasource Location... Select the database node (yellow-ish cylinder) of the current connection, then select the database node of the desired connection (you may need to authenticate), then click Update.

You will need to do this for the 'Subreports' nodes as well.

FYI, you can also do individual tables by selecting each individually, then choosing Update.

like image 45
craig Avatar answered Sep 20 '22 03:09

craig