Required namespace: usingCrystalDecisions. CrystalReports. Engine; usingCrystalDecisions. Web; usingCrystalDecisions. Shared; ---------------------------------------------------- create a dataset file *. xsd Partition -------------------------------------------
Required namespace: using CrystalDecisions. CrystalReports. Engine; using CrystalDecisions. Web; using CrystalDecisions. Shared; ---------------------------------------------------- create a dataset file *. xsd Partition -------------------------------------------
Required namespace
Using CrystalDecisions. CrystalReports. Engine;
Using CrystalDecisions. Web;
Using CrystalDecisions. Shared;
----------------------------------------------------
Create a dataset File
*. Xsd
-----------------------------------------------------
Add a report display control to the page.
CrystalReportViewer
--------------------------------------------------------
Background code
DsJob dsjob = new dsJob ();
SqlConnection scn = new SqlConnection ("server =.; uid = sa; pwd = 111111; database = pubs ;");
Scn. Open ();
SqlDataAdapter sda = new SqlDataAdapter ("select * from jobs", scn );
DataSet ds = new DataSet ();
Sda. Fill (ds );
If (ds! = Null & ds. Tables [0]. Rows. Count> 0)
{
Foreach (DataRow dr in ds. Tables [0]. Rows)
{
DataRow drjob = dsjob. Tables [0]. NewRow ();
Drjob ["job_id"] = dr ["job_id"];
Drjob ["job_desc"] = dr ["job_desc"];
Dsjob. Tables [0]. Rows. Add (drjob );
}
}
CrystalReportSource crysource = new CrystalReportSource ();
Crysource. ReportDocument. Load (Server. MapPath ("CryPort. rpt "));
// Assign a value to the text CONTROL ON THE CRYSTAL REPORT
TextObject textobj = (TextObject) crysource. ReportDocument. ReportDefinition. ReportObjects ["Text3"];
Textobj. Text = "chen ping ";
Crysource. ReportDocument. SetDataSource (dsjob );
Crysource. DataBind ();
Cryview. ReportSource = crysource;
Cryview. DataBind ();
// Assign a value to the text control on the report
TextObject txtname = (TextObject) crysource. ReportDocument. ReportDefinition. ReportObjects ["Control Name"];
Txtname. Text = "";