Required namespaces
Using CrystalDecisions.CrystalReports.Engine;
Using Crystaldecisions.web;
Using Crystaldecisions.shared;
----------------------------------------------------
Create a DataSet file
*.xsd
-----------------------------------------------------
Add a report to the page to view the control
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"));
Crysource. Reportdocument.setdatasource (Dsjob);
Crysource. DataBind ();
Cryview. ReportSource = Crysource;
Cryview. DataBind ();
Assign a value to a text control on a report
Textobject txtname = (textobject) crysource. reportdocument.reportdefinition.reportobjects["control name"];
Txtname. Text = "";
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