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