Use eclipse to display the Crystal Report on JSP (7) use the SQL command object as the data source 1

Source: Internet
Author: User

In my articleUse eclipse to display the Crystal Report on JSP (3) use SQL statements to filter dataIn. net, you can easily use SQL statements to filter report data. However, this function is not set in cr4e, but can be completed by coding. "In fact, it can also be done in eclipse, but I did not know it.

After tests over the past few days, I found that the SQL command object added to the report is completely different from a database dataset. The content of this dataset is determined when it is added to the report.

If you connect to the database, click "refresh" in the toolbar to synchronize the data to the database.

It is divided into two parts: cr4e1 and cr4e2.

1. cr4e1

IDE: Eclipse 3.2, database: SQL Server 2005

The key to directly using SQL command objects is "*. sqlpage "file. In the context menu of this file, we can see" craystal reports ", click to view the menu options of "add to new report" and "add to current report. from the two menu options, we can probably guess their role.

Yes, the SQL statements you write in the sqlpage file can be added to the current report or new report by running them to become a data source.

(1) create a sqlpage File

There are two methods to create a sqlpage file.

1. In the menu "file"-> "new"-> "other", select "data"-> "SQL scrapbook page" in the pop-up window"

2. Click the place in the red circle above through "Database Explorer.

(2) Write SQL in sqlpage

(3) Context menu of SSS. sqlpage

Click "Use Database Connection". In fact, whether you create or use a connection, it is related to "Database Explorer.

Click"Run SQL", This is the top priority. Only successfully executed SQL statements can be added to the report." run SQL "must be executed before each SQL statement is added to the report ".

The execution result is displayed in "dataoutput ".

 

(4) Add the SQL statement to the report. Because my report file "crystalreport1.rpt" already exists and is opened, I click "add to current report". If it is as follows:

"Sss" is the default sqlpage file name. You can change it to another name, such as "AAA". addressid is the select field. you can add the addressid field to the report.In this case, the data source SSS has nothing to do with SSS. sqlpage. You can repeat steps 2-4 to add other SQL result sets to the report.

Merge result:

Because there are too many images, the speed of opening the article will be greatly affected, so the cr4e2 part will be left in the next article

Use eclipse to display the Crystal Report on JSP (7) use the SQL command object as the data source 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.