. NET use Crystal Reports

Source: Internet
Author: User
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 = "";

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.