asp.net中使用水晶报表 ---push
首先要说明的是push比pull多了一层DataSet所以我们来创建一个
还需要创建一个报表
导入命名空间
private void Show() { DataSet ds=new DataSet(); string connStr = "server=.;database=demo;uid=sa;pwd=12345"; using (SqlConnection conn=new SqlConnection(connStr)) { conn.Open(); string sql1 = "select * from Dept"; string sql2 = "select * from UserInfo"; SqlDataAdapter da = new SqlDataAdapter(sql1, conn); da.Fill(ds, "Dept"); da = new SqlDataAdapter(sql2, conn); da.Fill(ds, "UserInfo"); } ReportDocument rd = new ReportDocument(); rd.Load(Server.MapPath("~/Report/CrystalReport1.rpt")); rd.SetDataSource(ds); CrystalReportViewer1.ReportSource = rd; }
然后就可以在浏览器中查看
Hold on, everything is possible.