Creating and Setting Up Crystal Reports for Windows Applications

In this section of the tutorial we:

To create and setup a Crystal Report:

  1. Open Visual Studio, and then select File > New > Project.

The New Project dialog box displays.

  1. Select the programming language from the Project Types list (in this tutorial, the project is created in Visual Basic), and then select Windows Application from the Templates list.

  1. Type a name for the project in the Name text box (in this tutorial, the project is named CrystalReport), and then click OK.

The new design form displays.

  1. Select the Data tab from the Toolbox, and then drag-and-drop a PickDPConnection, PickDPCommand, and a PickDPDataAdapter control to the form.

  2. Specify the account to connect to by setting the ConnectionString property of the Connection control from the Properties dialog box (in this tutorial, the Demo_PickDP account is specified).

  3. Specify the connection to be used by the PickDPCommand control from the Properties dialog box (in this tutorial, the PickDPConnection1 is specified).

  4. Select and open the CommandText property of the PickDPCommand control from the Properties dialog box.

The PickDPADO.Net - Query Builder displays.

  1. Select the Table to use for building the query from the Select a Table below list (in this tutorial, the CUSTOMERS Table is specified).

The list of existing queries displays in the Select a Query list. Note that you can either specify an existing query to use or design a new query (in this tutorial, we design a new query).

  1. Click New.

  2. Specify the items to output in the report and any sorting criteria from the Select the columns to Output, Sort, and Select list (in this tutorial, the CUST_CODE, COMPANY_NAME, ADDRESS, CITY, STATE, and ZIP_CODE items are specified for output), and then click Test Query.

The specified output displays in the Results tab.

  1. Click the Query Builder tab, and then click Save.

The Enter the query Name dialog box displays.

  1. Type a name for the new query  (in this tutorial, the query is named Cust_Address), and then click Accept.

The new query name displays in the Select a Query list.

  1. Select the new query from the Select a Query list, and then click Accept.

The specified query is added to the PickDPCommand control.

  1. Set the SelectCommand property of the PickDPDataAdapter control to the new PickDPCommand control.