Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

13.10 Changing the Data Source

Changing the Data Source

Many reports are very simple and all the tables come from the same data source. The tables that are used when you designed the report are the same tables that will be used when the application is put into production. But this isn’t always the case. It is common for the requirements to change and for a report to use a data source different from what it was designed with. Or, you may have a development server that is used for designing the application and a production server that is used when the application is finished.

Crystal Reports has a number of features that make it easier to change the location of the tables. It lets you set the location of a data source, change the name that a table is referenced by, and verify whether a database is valid.

Set Location Dialog Box

The Set Location dialog box, shown in Figure 13-8, is used to change the data source of an existing table. You might need to do this when the reporting requirements change, or when you find that, after having used one data source for coding and testing, you have to change to the production data source before releasing the program.



Figure 13-8. The Set Location dialog box.

The Set Location dialog box lets you replace an existing data source with a new data source. You can switch the database server so that all the tables from one server are switched to a different server. You can also change the data source for just one table and it won’t affect the other tables in that report. This includes changing the database server for that table or switching out the table for a totally different table.

Open the Set Location dialog box by selecting the menu options Crystal Reports > Database > Set Location. It has a window labeled “Current Data Source”. This lists the current connections and any tables that are being used with that connection. The window at the bottom is labeled “Replace With”. It lists the same data sources that are displayed in the Database Expert dialog box.

To replace the entire data source for all the tables, select that database server from the Current Data Source window on the left.

To replace a single table, drill down to select the specific table. The other window is refreshed to display the information about the table.

The Replace With window is where you select the data source that will replace what was selected in the combo box. Scroll through this window to find the new data source. If the Current Data Source combobox lists a database server, choose a database server within the Replace With window. If the Current Data Source is a table, you have to have a table selected within the Replace With window.

When both the current data source and the new data source are selected, click the Replace button. The existing data source gets replaced with the new data source.

If you find that the Replace button isn’t enabled, you haven’t selected data sources that are compatible with each other. For example, if you have a table selected, you have to have a table selected in the Replace With window. If there is a data source selected, then the Replace With window can’t have a table selected.