Setting a Database Alias

Aliases are used when you need to reference a table in a report more than once. A common example would be where you had an employee table with a supervisor ID that was also the employee ID of the supervisor. To get Crystal Reports .NET to reference the same table, you would need to add it to the report a second time, and give it an alias like EmployeeSupervisor.

To set a database alias, open the Database Expert by right-clicking and selecting Database ^ Add/Remove Database. In the window on the left, find and then double-click the database or table you want to apply the alias to, and the dialog shown in Figure 7-13 will open.

Figure 7-13

Select Yes, and enter the new alias for the database in the Alias Name dialog, shown in Figure 7-14.

Figure 7-14

You will see your new alias in the right-hand window of the Database Expert, with the alias you specified in the previous dialog, shown in Figure 7-15. You can edit this name by selecting the table in the Selected Tables window, and pressing F2.

This will only change the alias of the datasource within Crystal Reports .NET and will not touch the underlying SQL statement. Selecting OK will accept this and present you with the Visual Link Designer, as seen in Figure 7-16, which you can use to change the links between the different tables, as we described earlier in this chapter.

H Database Expert m


Links. I

Qrowse the data source for the tables you want to add to youi report.

[N ofe: tc edit the alias for a '.able, choose a selected table you wish to change then click ori it or push the F2 key)

Available Data Sources:: Selected Tabled

+ ClFroiectDala


. CjjDLE DB ¬°ADO)

Was this article helpful?

0 0

Post a comment