手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >.NET 水晶报表使用代码
.NET 水晶报表使用代码
摘要:需要的命名空间usingCrystalDecisions.CrystalReports.Engine;usingCrystalDecisio...

需要的命名空间

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Web;

using CrystalDecisions.Shared;

----------------------------------------------------

建一个数据集文件

*.xsd

-----------------------------------------------------

在页面中加一个报表查看控件

CrystalReportViewer

--------------------------------------------------------

后台代码

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();

//给报表上的 text 控件赋值

TextObject txtname = (TextObject)crysource.ReportDocument.ReportDefinition.ReportObjects["控件Name"];

txtname.Text = "";

【.NET 水晶报表使用代码】相关文章:

asp.net 多字段模糊查询代码

ASP.NET常用代码

AspNetPager与Socut.Data使用实例代码

ASP.NET 导出到Excel时保留换行的代码

ASP.NET 高性能分页代码

在ASP.NET中重写URL的代码

ASP.NET中常用的三十三种代码第1/7页

asp.net SqlHelper数据访问层的使用

ASP.NET中application对象的使用介绍

ASP.NET中的Cache使用介绍

精品推荐
分类导航