Adding Objects to the Repository

Depending on the type of object that is going to be saved in the repository, different methods of adding them are required. All repository objects can be added in an intuitive way. Report objects can be dragged and dropped, SQL commands can be added when the commands are written, and custom functions can be added from the Formula Workshop. Let's look at the different processes more closely.

Text Objects and Images

Repository Objects can be added to the repository in folders contained in a tree structure. To add a new object to the repository, a simple drag-and-drop is all that's required:

  1. Take the object on the design or preview surface and drag it to its rightful place in the Repository Explorer.

  2. If a folder location is warranted, simply drag the object over the folder until the folder opens and then let go. The Repository Properties dialog will appear.

  3. Enter the relevant information (such as the name of the object) and click OK.

An alternative way to store an object in the Repository is to right-click on the object in the report design or preview. From the context menu, choose Add to Repository. A more complex properties dialog will appear. Add the name, and so on (as previously mentioned), as well as choose the location for the object as the last step in this dialog. (This step was avoided in the drag and drop scenario because the location was implied in that procedure.)

SQL Commands

Imagine that you have a fairly difficult SQL (Structured Query Language) statement that you want to share with others, but you want to control it in case changes need to be made at a later time. This can be done using SQL Commands and saving them in the Repository.

SQL Commands can be added to the Repository from the Data Explorer or the Data step of the Report Wizard. The steps are the same for both, so let's use the Data Explorer to illustrate.

  1. Connect to the database desired in the Available Data Sources list box and choose Add Command from the list of available options. Select Add Command by double-clicking on it. This will bring you to the Add Command to Report dialog.

  2. Enter the SQL statement you want into the query box. If parameters are required, you can use this dialog to create them as well. An example would be

     "SELECT `Employee`.`Last Name`, `Employee`.`First  Name`,`Employee_Addresses`.`Address1`, `Employee_Addresses`.`Address2`, `Employee_Addresses`.`City`, `Employee_Addresses`.`Region`, `Employee_Addresses`.`Country`, `Employee_Addresses`.`Postal Code`, FROM `Employee` `Employee` INNER JOIN `Employee Addresses` `Employee_Addresses` ON `Employee`.`Employee ID`=`Employee_Addresses`.`Employee ID` " 

    graphics/bookpencil_icon.gif

    For more in-depth information on Structured Query Language and using SQL Commands, see Hour 22, "Optimizing SQL Queries in Crystal Reports."


  3. Before leaving this dialog, make sure that the Add to Repository option at the bottom of the dialog is selected, and then select OK.

  4. The Add Item dialog will appear (similar to the dialog for text objects and images). Select a name for the command and a location in the Repository.

graphics/alarmclock_icon.gif

If the name of the command has spaces in it, keep in mind that many of the data access drivers will convert them to underscores _. See Hour 3, "Accessing Your Data," for more information on data access drivers.


graphics/bookpencil_icon.gif

Notice that descriptions are not as free form as they were with text objects and images. By default, they contain the SQL statement, but this can be edited, appended to, or simply removed. It is included as a default because most report designers have requested to see the results of the statement.




Sams Teach Yourself Crystal Reports 9 in 24 Hours
Sams Teach Yourself Crystal Reports 9 in 24 Hours
ISBN: B003D7JUVW
EAN: N/A
Year: 2005
Pages: 230

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net