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