水晶报表的PUSH模式与 PULL模式
来源:互联网 发布:罗马全面战争mac版 编辑:程序博客网 时间:2024/04/28 02:43
本文转自:http://www.cnblogs.com/greencolor/archive/2010/05/02/1726082.html
拉模式:在水晶报表生成时的数据源是从水晶报表文件中的SQL语句从数据库中提取的,在编程时不用重写SQL语句,但要加上登录信息(具体方法,后面介绍)。推模式:在水晶报表生成时的数据源,是用编程时重写水晶报表中SQL语句而生成的dataset对像。
使用PUSH模式
我们采用下面的几步使用Push模式执行水晶报表:
1. 设计一个DataSet
2. 创建一个.rpt文件同时将其指定给上一步建立的DataSet。
3. 在aspx页面中拖放一个CrystalReportViewer控件同时将其与前面的rpt文件建立联系。
4. 在代码中访问数据库并把数据存入DataSet
5. 调用DataBind方法。
设计一个DataSet
1) 右击“解决方案浏览器”,选择“添加”--“添加新项”-->“数据集”
2) 从“服务器资源管理器”中的“SQL Server”中拖放“ProjectStage”表(位于dbname数据库中)。
3) 此时在数据集中就会有一个ProjectStage表的结构图。
- .xsd文件中仅仅包含一个结构图,但是不会有任何数据在里面。
创建 .rpt 文件 :
4) 使用上面的介绍过的方法创建此文件,唯一的不同就是使用数据集来代替前面的直接连接数据。
5)建立.rpt文件之后,右击“详细资料”-->"添加/删除数据库“
6) 在”数据库专家“窗口中,展开”项目数据“(代替以前的OleDb),展开“ADO.Net数据集”--"DataSet1“,选择”ProjectStage“表。
7) 将”ProjectStage"表添加到“选定的表”中,点击“OK”
Code Behind 代码:
PUSH model FORM
string strProvider = "Server=.;DataBase=dbname;UID=sa;PWD=sa";
CrystalReport1 oCR = new CrystalReport1();
DataSet1 ds = new DataSet1();
SqlConnection MyConn = new SqlConnection(strProvider);
MyConn.Open();
string strSel = "Select * from ProjectStage";
SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel, MyConn);
MyAdapter.Fill(ds, "ProjectStage");
oCR.SetDataSource(ds);
this.crystalReportViewer1.ReportSource = oCR;
PULL model FORM
CrystalReport1.Load(Application.StartupPath + "CrystalReport1.rpt");
CrystalReport1.SetDatabaseLogon("sa", "sa", "servername", "dbname");
crystalReportViewer1.ReportSource = CrystalReport1;
PUSH model WEB
string sql = "Select * FROM ProjectStage";
string DBConfig_sql ="Data Source=.;Initial Catalog=dbname;User ID=sa;Password=sa";
DataSet1 ds = new DataSet1();
SqlConnection sqlCon = new SqlConnection(DBConfig_sql);
SqlCommand sqlCmd = new SqlCommand(sql, sqlCon);
SqlDataAdapter sqlAd = new SqlDataAdapter();
sqlAd.SelectCommand = sqlCmd;
sqlAd.Fill(ds, "ProjectStage");
CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["ProjectStage"]);
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
PULL model WEB
CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "sa", "servername", "aa");
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
- 水晶报表的PUSH模式与 PULL模式
- [水晶报表]PUSH与PULL模式
- Pull模式水晶报表
- 水晶报表pull与push
- 水晶报表PUSH模式
- 水晶报表PUSH模式
- Push模式下水晶报表的若干问题
- 水晶报表push模式的应用
- Push模式下水晶报表的若干问题
- PUSH模式动态水晶报表的实现
- 水晶报表VS2008 - PULL模式
- 水晶报表PUSH模式在WINFORM与WEBFORM中的应用
- web水晶报表pull模式解决方案
- Winform基础水晶报表-Pull模式
- 阿泰,水晶报表--pull模式样板
- Pull模式水晶报表(统计+图表)
- 水晶报表十二式-------详解PULL模式
- 水晶报表的Push模式及多表制作
- VirtualBox 使用技巧 教程一 VirtualBox安装增强功能
- Re-informed By Tao --- A Mathematica Friend
- 终于还是写了
- 【STM32 .Net MF开发板学习-1】蓝牙遥控智能小车(PC模式)
- linux 解压命令
- 水晶报表的PUSH模式与 PULL模式
- 使用面向对象的技术创建高级 Web 应用程序(JavaScript)
- Oracle中表的连接及其调整(1)
- 踏上这片土地
- Oracle中表的连接及其调整(2)
- 从一个SQL使用了不理想的执行计划说开,浅谈执行计划如何估算cache信息的影响及系统统计信息的收集等(2010-10-15)
- POJ 3984 迷宫问题 解决报告
- 文件路径常用操作
- VirtualBox 使用技巧 教程二 VirtualBox与主机Windows共享文件