日期:2014-05-20 浏览次数:20878 次
private ReportDocument myArea; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Initialize(); } } private void Initialize() { CRBind(); } private void CRBind() { DataSet ds = new DataSet(); string strSql = "select p.name as Province,c.name as City, a.name as Area,a.code as ZIP from province p left join city c on p.code=c.fid left join area a on c.code=a.fid"; using (SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AreaDB"].ConnectionString)) { SqlDataAdapter sda = new SqlDataAdapter(strSql, Conn); sda.Fill(ds,"Area"); } string filePath = Server.MapPath("CrystalReportPush.rpt"); myArea = new ReportDocument(); myArea.Load(filePath); myArea.SetDataSource(ds.Tables["Area"]); CrystalReportViewer1.ReportSource = myArea; CrystalReportViewer1.DataBind(); } }
<compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>