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

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.

Ii. cr4e2

IDE: Eclipse 3.4, database: SQL Server 2005

The key to directly using SQL command objects is "*. SQL "file. In the context menu of this file, we can see" craystal reports ". Click in to see" add to new report (add to New Report) "and" add to current report (add to existing report) "menu options. from the two menu options, we can probably guess their role.

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

(1) Create an SQL File

There are two ways to create an SQL file.

1. Choose "file"> "new"> "other" from the menu. In the displayed window, select "SQL development"> "SQL File"

2. Click "Data Source Explorer" in the red circle above.

(2) Write SQL In the mysql. SQL file. Note that you must connect to the database before performing operations.

(3) Right-click mysql. SQL

Click "execute all" to execute the SQL statement. The execution result is displayed in "SQL results ".

 

The "SQL results" interface is much simpler than before.Only the result set of the successfully executed SQL statement can be added to the report.Execute each time you add an SQL result set to a report.

Click "edit in SQL Query Builder". The window is displayed. This is just a tool that allows you to combine SQL statements. It feels like the "Enterprise Manager" of SQL Server 2000 to create a view.

"Edit in SQL Query Builder": the SQL statement that is successfully executed must be copied to MySQL. SQL before it can be added to the report.

(4) Add the SQL statement to the report.

After the SQL statement is successfully executed, click "add to current report". Unlike sqlpage, this window is displayed:

 

More user-friendly than before. Select the rpt file and click "OK". The result is as follows:

 

"MySQL" is the name of the SQL file by default. You can change it to another name. addressid is the select field. you can add the addressid field to the report. in this case, the data source MySQL is actually the same as MySQL. SQL is irrelevant. You can repeat steps 2-4 to add other SQL statements to the report.

Merge result:

Cr4e1

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

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.