• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

VB程序打印水晶报表的典型方法1

发布: 2007-7-02 11:08 | 作者: admin | 来源: | 查看: 13次 | 进入软件测试论坛讨论

领测软件测试网
描述:

 

  本文介绍流行的一种VB程序打印水晶报表的方法,具有比较好的扩展性.

 

环境:

   MS SQL SERVER 2000  /  VB6  /  CRYSTAL REPORT8.5

 

步骤

 

1: 建立ODBC连接

 

2: 创建一个为Crystal Report检索数据的过程(procedure)

举例: (通过日期查询总额)

   if exists (select * from sysobjects where name = @#usp_testfjs@#)

            drop proc usp_testfjs

   go

   create proc usp_testfjs

            @strDate varchar(20)

   as

        select sum(tot_amt) as total_amount

        from trans_header

        where convert(varchar(10),bus_dt,120) = @strDate

   go

 

3. 创建使用procedure的crystal 报表

   步骤和创建一般报表相同,但是注意在选择数据源时,把options中的Stored Procedures勾上

  

4. 创建VB程序

   注意加入一个水晶报表控件(crystal report control)

   一段最简单的程序:

   例如:

   Private Sub Command1_Click()

        Dim iRet As Integer

        CrystalReport1.Reset  /*Reset Data*/

 CrystalReport1.ReportFileName = App.Path + "\totalamount.rpt"

/*Link the Crystal Report Control with actual rpt file */

        CrystalReport1.StoredProcParam(0)= Format(Trim$(DTPicker1.Value), "yyyy-mm-dd")

/*Assign the Parameter*/

        CrystalReport1.WindowState = crptMaximized

        CrystalReport1.WindowTitle = "HELLO"

        iRet = CrystalReport1.PrintReport

/*Retrieve the Data and display the Printpreview Screen */

 

总结:

   这个方法实现了水晶报表和VB程序的独立性,用户对于报表格式的改变将被局限于水晶报表的修改范围中. 建议大家采用这种方法.

  

 

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网