官方水晶报表.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文件的表名、列名对应