Experience in using Crystal Reports 2-use SQL statements to directly generate dataset as the report data source!

Source: Internet
Author: User
The last time I made the method of using oledb to connect to the database directly in the rpt file, but it was not very flexible. This time I used SQL statements to directly generate dataset as the report data source (that is, the push mode ), in this way, you can accept the parameter. Of course, I have not studied the function of setting parameters in reports in detail.

I. Table association is not used in SQL statements (simple query statements)
  Design Dataset
1) Right-click"Solution Browser", Select"Add"--"Add new item"-->"Dataset"
2) Slave"Server Resource Manager"In"SQL Server"Drag and Drop"Stores"Table (located inPubsDatabase)
3) A stores table structure is created in the dataset. XSD the file contains only one structure chart, but no data is in it

Create . Rpt The crystalreport1.rpt file is also specified to Dataset .
4) Use the method described above to create this file. The only difference is that you can use a dataset to directly connect to the previous data.
5) Create. RptRight-click the file"Details"-->"Add/delete database"
6) In"Database Expert"Window, expand"Project Data"(Replace the previousOledb), Expand"ADO. netDataset"--" Dataset1", Select"Stores"Table.
7) Set"Stores"Add Table"Selected table", Click"OK"
8) CreateWebform1.aspx drag-in OneCrystal Report ViewerWidget

9)Webform1.aspx. CS
ReportDocument orpt = new reportdocument ();
String rptdir = "F: \ BBS \ test \ crystal \ crystalreport1.rpt ";
Orpt. Load (rptdir );

... // Obtain dataset based on SQL statements.

Orpt. setdatasource (DS );
Crystalreportviewer1.reportsource = orpt;

// Note that the logoninfo parameter cannot be set in Push mode.

10) run it! It should be okay.
Also sent to the Crystal Report 10 download: http:// SC .fixdown.com/fixdown/download.asp? Id = 14867 & free = SX-down

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.