Ok

Cancel

Help

Figure 7-9

Using the dialog, you can draw links between the databases and tables in your report to indicate the relationship between each. To draw a line between two fields, imitate dragging the first field and dropping it on top of the second. You will know you have the field positioned correctly when your cursor turns into the shortcut icon.

If you make a mistake, you can remove a link by clicking the line to highlight it and pressing the delete key, or to clear all links, use the button of the same name on the right-hand side of the expert.

Our earlier example was very simple; in the Visual Linking Expert you can create multiple links between tables if your database schema requires them.

By default, Crystal Reports will join two SQL tables with an Equal join. To change the default join type, right-click directly on the line drawn between the two tables and select Link Options from the menu, shown in Figure 7-10.

Figure 7-10

Using the Link Options dialog, select a join type for this link from the following list:

□ Right Outer Join

You can also select an operator to work with the join type you have selected, including:

Operator

Description

=

Equal To

>

Greater Than

>=

Greater Than or Equal To

<

Less Than

<=

Less Than or Equal To

!=

Not Equal To

At any point you can click the Auto-Arrange button to arrange the Visual Linking Expert layout for readability, but sometimes you will get better results if you position the tables yourself.

If it's still open from the last example, take a look at employee_profile.rpt in Crystal Reports .NET. The report has been created from the Employee and Employee_Addresses tables. To see the SQL that Crystal Reports .NET has generated, right-click the report, and select Database ^ Show SQL Query:

SELECT "Employee"."Last Name", "Employee"."First Name", "Employee"."Birth Date", "Employee"."Hire Date", "Employee_Addresses"."City"

FROM "Employee" "Employee" INNER JOIN "Employee Addresses" "Employee_Addresses" ON "Employee"."Employee ID"="Employee_Addresses"."Employee ID"

The fields you select in your report control the contents of the SELECT statement, but it is the links that control the FROM clause. When working with multiple tables or a large database, your database administrator should be able to give you some guidance on how the tables should be arranged and joined together.

If you find working with links in Crystal Reports .NET difficult, you can always use an SQL command as the datasource for your report, and perform any joins in the SQL statement you write.

Was this article helpful?

0 0

Post a comment