在 Visual Studio .NET中使用Crystal Report(下) (cashcho翻
來源:互聯網
上載者:User
在 Visual Studio .NET中使用Crystal Report(下)
from www.aspfree.com
translated by cash(天下第七)
cashcao@msn.com(cashcao@msn.com)
Crystal Report 示範-使用Push Model
下面看看如何使用Push Model實現Crystal Reports
1.建立一個設計時的dataset
2.建立一個.rpt檔案並指向我們前面建立的dataset
3.在.aspx頁面上放置Crystal Report Viewer控制項,設定它的屬性指向上一步建立的.rpt檔案。
4.在code behind page中,書寫串連資料庫的函數
5. 加上databind方法。
建立一個設計時的dataset去定義Reports的Fielsds.
1)在"Solution Explorer"右擊,選擇"Add" --> select "Add New Item--> Select "DataSet"
2) 從"Server Explorer"面板中的"SQL Server"中拖進"Stores"表
3) 這將在dataset中建立一個"Stores" table
用這種方法建立的.xsd檔案僅僅包含了field的定義,裡面沒有任何資料。需要你建立一個與資料庫的連結並且將資料填充進去。
建立.rpt檔案
4)建立一個.rpt檔案。與前面唯一不同的是不通過Crystal Report得到表,我們將用dataset來建立它。
5)建立.rpt檔案後,右擊"Details" section,選擇"Add/Remove Database"
6) 在"Database Expert"視窗,展開"Project Data",展開"ADO.NET DataSet","DataSet1", 選擇 "Stores" table.
7)點擊">"將"Stores" table包括進"Selected Tables"
8) 接下來設定report的布局。