.NET 水晶報(bào)表使用代碼
更新時(shí)間:2009年04月26日 14:07:08 作者:
下面就是介紹在.net下,如何使用水晶報(bào)表的方法。
需要的命名空間
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
----------------------------------------------------
建一個(gè)數(shù)據(jù)集文件
*.xsd
-----------------------------------------------------
在頁(yè)面中加一個(gè)報(bào)表查看控件
CrystalReportViewer
--------------------------------------------------------
后臺(tái)代碼
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();
//給報(bào)表上的 text 控件賦值
TextObject txtname = (TextObject)crysource.ReportDocument.ReportDefinition.ReportObjects["控件Name"];
txtname.Text = "";
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
----------------------------------------------------
建一個(gè)數(shù)據(jù)集文件
*.xsd
-----------------------------------------------------
在頁(yè)面中加一個(gè)報(bào)表查看控件
CrystalReportViewer
--------------------------------------------------------
后臺(tái)代碼
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();
//給報(bào)表上的 text 控件賦值
TextObject txtname = (TextObject)crysource.ReportDocument.ReportDefinition.ReportObjects["控件Name"];
txtname.Text = "";
相關(guān)文章
ASP.NET?Core中引用OpenAPI服務(wù)的添加示例
這篇文章主要為大家介紹了ASP.NET?Core中引用OpenAPI服務(wù)添加示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-04-04swfupload ajax無(wú)刷新上傳圖片實(shí)例代碼
在這里上傳圖片就需要用到ajax無(wú)刷新上傳圖片,這里面包含的東西不是一點(diǎn)半點(diǎn)。這里用到的是一個(gè)插件swfupload實(shí)現(xiàn)無(wú)刷新上傳圖片,感興趣的朋友可以參考下哈2013-06-06ASP.NET 防止按鈕多次提交核心實(shí)現(xiàn)代碼
防止按鈕多次提交通常都是在注冊(cè)表單中提示時(shí)的一個(gè)小功能,具體實(shí)現(xiàn)如下,由此需求的朋友可以參考下2013-08-08Asp.net core Web Api配置swagger中文的實(shí)現(xiàn)
swagger是一個(gè)api文檔自動(dòng)生動(dòng)工具,還集成了在線調(diào)試. 可以為項(xiàng)目自動(dòng)生成接口文檔, 非常的方便快捷,具有一定的參考價(jià)值,感興趣的可以了解一下2023-09-09asp.net實(shí)現(xiàn)圖片以二進(jìn)制流輸出的兩種方法
這篇文章主要介紹了asp.net實(shí)現(xiàn)圖片以二進(jìn)制流輸出的兩種方法,以簡(jiǎn)單實(shí)例形式分析了asp.net實(shí)現(xiàn)以二進(jìn)制流形式讀寫(xiě)圖片文件的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12關(guān)于多對(duì)多關(guān)系表無(wú)法更新與插入的問(wèn)題
這篇文章主要介紹了關(guān)于多對(duì)多關(guān)系表無(wú)法更新與插入的問(wèn)題 的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07ASP.NET:設(shè)置頁(yè)面buffer引出來(lái)的問(wèn)題
ASP.NET:設(shè)置頁(yè)面buffer引出來(lái)的問(wèn)題...2006-09-09