Crystal Report Using Experience 2-- Use the SQL statement to directly generate DataSet as the data source of the report! The last time I did myself using the OLEDB connection using the OLEDB connection directly in the RPT file, but I didn't have flexible this time, I did the data source (ie, PUSH mode) that uses the SQL statement to generate DataSet, so that the parameters can be accepted. Of course, the report has the function of setting parameters. I have not study in this regard.
I don't use the interrelation of the table in the SQL statement (simple query statement)
Design one
DataSet
1) Right-click "Solution Browser", select "Add" - "Add New Item" -> "Data Set"
2) Drag and drop the "Stores" table from "SQL Server" in "Server Explorer" (located in the Pubs database)
3) There will be a structural diagram of a Stores table in the data set. There is only one structural diagram in the XSD file, but there will be no data in it.
Create
.rpt
File CrystalReport1.rpt also assigns it to the previous step
DataSet
. 4) Creating this file using the methods described above, the only difference is to use the data set to replace the front direct connection data. 5) After establishing .rpt file, right-click "Details" -> "Add / Remove Database" 6) In the Database Expert window, expand "Project Data" (replace the previous OLEDB), expand "ADO.NET Data Set "-" Dataset1 ", select" Stores "table. 7) Add the "Store" table to "Selected Table", click "OK" 8) to create a WebForm1.aspx drag into a Crystal Report Viewer control
9) Webform1.aspx.cs reportDocument orpt = new reportDocument (); string rptdir = "f: //bbs/test//crystal//crystalreport1.rpt"; oorpt.load (rptdir); ... // The SQL statement gets DataSet, there is not much ORPT.SetDataSource (DS); CrystalReportViewer1.ReportSource = ORPT; / / Note Push mode does not use the LogonInfo parameter 10) Run Try! There should be no problem, please send another crystal report 10 download: http://sc.fixdown.com/fixdown/download.asp? Id = 14867 & free = SX-DOWN
Posted on 2004-02-05 11:22 Zsww Read (1624) Comments (7) Edit Collection