官方水晶報表.NET 應用程序實例下載(C#、Visual C++.NET)
http://www.weste.net/html/200408/20040825QBI101746.html
1、升級
下載水晶報表10。安裝時選擇.NET組件。如果VS2003已經安裝好會自動將其內置水晶報表升級為10
License : AV860-01CS00G-U7000NC SN : 1231467890
2、使用
拖一個CrystalReportViewer到Form上
添加新項目,選擇水晶報表。安裝向導連接數據庫選擇表即可建成rpt文件。
添加如下代碼:
private void Page_Load(object sender, System.EventArgs e)
{
initDataSet();
//Create an instance of the strongly-typed report object
LotTrackCross crReportDocument = new LotTrackCross();
//Pass the populated dataset to the report
crReportDocument.SetDataSource(dataSet);
//Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument;
}
private void initDataSet()
{
string querySql ="select * from tblLotTrack where lot< 535120 and stn < 5000 ";
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= c:\LTS2005.mdb");
cn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(querySql,cn);
adapter.SelectCommand = new OleDbCommand(querySql, cn);
adapter.Fill(dataSet);
}
注意:填充使用的DataSet要和建立rpt文件的表名、列名對應