VS2005中水晶報表在C#.NET WEB應用程式中與ADO.NET的結合(收藏)
a 建立ADO.NET資料集---DataSet1.xsd
b 建立CrystalReports--CrystalReport.rpt
c 設計WEB頁面 拉入報表顯示控件---CrystalReportViewer
d 相關後台編碼
添加相關引用
連接數據庫
用相關查詢的結果填充DataSet1的實例對象
建立ReportDocument--rptDoc
rptDoc載入報表 rptDoc.Load("...")
設定rptDoc的資料來源 rptDoc.SetDataSource(ds)
通過頁面的報表檢視器顯示報表 crViewer.ReportSource = rptDoc
實例步驟:
1 新建web專案
2 在專案中新增ADO.NET資料集-DataSet1.xsd
專案右鍵-加入新項目-資料集
3 建立資料連接
伺服器總管-資料連接-右鍵-加入資料連接
4 將資料表(如tablename)放入剛才所建的資料集
具體就是從資料庫中將該表拉入資料集設計界面即可
5 儲存並建置專案
-----------
6 新增Crystal Reports報表-CrystalReport.rpt
專案-右鍵-加入新項目-Crystal Reports
7 使用標准報表專家 建立報表
8 使用ADO.NET資料集 做為資料來源
9 選擇加入相關表的相關樣位到報表中顯示
10 使用標准樣式
11 儲存並建置專案
----------
12 設計表單 拉入工具樣中的 CrystalReportViewer
13 編寫該WEB頁面的後台代碼
14 加入如下參考:
using System.Data.SqlClient
usint CrystalDecisions.CrystalReports.Engine
15 在適當位置編寫如下相關代碼
建立資料庫連線
SqlConnection sqlconn = new SqlConnection("server=localhost;database=db;uid=uid;pwd=pwd;");
sqlconn.Open();
建立SQL指令
SqlDataAdapter sda = new SqlDataAdapter("select * from table", sqlconn);
取回資料放入資料集
DataSet1 ds = new DataSet1();//注意 此處用的是 剛才所建立的資料集 而不是慣用的DataSet
sda.Fill(ds, "tablename");//注意 此處的tablename 要與剛才在建立資料集時 用到的tablename相同
建立報表物體-rptDoc
ReportDocument rptDoc = new ReportDocument();
載入報表-CrystalReport.rpt
rptDoc.Load(this.Server.MapPath("./").ToString() + "/CrystalReport.rpt");
將報表物體的資料來源設定為ds
rptDoc.SetDataSource(ds);
以報表檢視器顯示報表
this.CrystalReportViewer1.ReportSource = rptdoc;
this.CrystalReportViewer1.DataBind();
------------
編譯運行 查看效果
原文地址:https://www.geek-share.com/detail/2375638760.html
转载于:https://www.cnblogs.com/CodingPerfectWorld/archive/2010/04/27/1722376.html
- VS2005中水晶報表在C#.NET WEB應用程式中與ADO.NET的結合(收藏)
- VS2005中水晶報表在C#.NET WEB應用程式中與ADO.NET的結合
- VS2005中水晶報表在C#.NET WEB應用程式中與ADO.NET的結合
- VS2005中水晶報表在C#.NET WEB應用程式中與ADO.NET的結合
- 終極解決“Visual Studio .NET 偵測到您的Web伺服器不是ASP .NET 1.1 版,您將無法執行Asp .NET的應用程式或服務。”
- web水晶報表在轉入WORD,EXCEL,PDF時出現:拒絕訪問報表檔案。其他程式可能正在使用它1/18
- Web应用中,利用vs.net 2003部署水晶报表
- 利用SQLite ADO.NET在.NET(C#)中使用SQLite数据库
- 建立ASP.NET Ajax應用程式
- 【收藏】本周ASP.NET英文技术文章推荐[01/27 - 02/02]:负载均衡、State Server、Web Deployment、Data Entry Suite、GridView、Access、SQL Server、MSDE
- ASP.NET之WEB项目中水晶报表的使用
- [C#.NET][VB.NET] Winform 應用程式等級的例外捕捉 / Winform Application of Level wicth Exception Catch
- ASP.NET 学习二 内容摘自msdn收藏 How to: Determine How ASP.NET Web Pages Were Invoked
- ASP.NET 出現訊息「伺服器應用程式無法使用」解決方法
- ADO.NET EF+Oracle的WEB服务器配置
- [转] VS2005制作Web安装程序 [http://blog.csdn.net/rainbowsoftware/archive/2007/08/01/1721296.aspx]
- 【转】[C#.NET][VB.NET] 用 Win32 API 控制 外部應用程式選單
- 伺服器應用程式無法使用,系統管理員注意:Web伺服器的應用程式事件記錄檔中的錯誤信息詳細說明了這項特定要求失敗的原因 請檢閱這個記錄項目,查看造成這個錯誤的原因為何
- .NET Framework Security Code Access Security-應用程式篇
- ASP.NET AJAX安装(VS2005下安装)收藏