日期:2014-05-18 浏览次数:20386 次
using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; private ReportDocument customerReport; Conn myconn = new Conn(); DataTable mytable = new DataTable(); static string selsql = ""; #region[绑定水晶报表数据] /// <summary> /// 绑定水晶报表数据 /// </summary> /// <param name="selsql">查询语句</param> private void ConfigureCrystalReports(string selsql) { string path = Server.MapPath("~\\rpt\\Budget.rpt");//报表的相对路径 customerReport = new ReportDocument(); customerReport.Load(path); DataSet dataSet = new DataSet(); dataSet = myconn.QueryDataSet(selsql, "Budget_two");//这是你的数据集 customerReport.SetDataSource(dataSet.Tables[0]); CrystalReportViewer1.ReportSource = customerReport; CrystalReportViewer1.DataBind(); } #endregion