All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
SQL Server 2005 存储过程写报表举例_[SQL Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/3 6:34:55 Browse times: 417 Comment times: 0

SQL Server 2005 存储过程写报表举例_[SQL Server教程]


Head photo

Go homepage
Upload pictures
Write articles

SQL Server 2005 存储过程写报表举例_[SQL Server教程]

听说MS SQL 2005自带报表功能,于是我测试了一下,还算比较好用,所以我就录了一个用存储过程来写报表的例子。由于测试过程当中没有语音,所以我在这里讲解一下。

使用的存储过程如下(录象中到最后我更改了一下存储过程):

使用的数据库是MS SQL 2000的Northwind数据库,表是orders。

if exists(select * from sysobjects where name='procTest' and xtype='P')drop proc procTestgocreate proc procTest@CustomerId varchar(20)asif @CustomerId='*'select * from Orderselseselect * from Orders where CustomerID=@CustomerId

可以用exec procTest 'VINET' 或者exec procTest '*'来测试

之后建立数据库报表项目

1、建立数据源

2、建立新的报表

3、建立数据集,这里我采用了特殊的方式,因为报表设计界面需要列出字段,所以我将存储过程中需要输出的字段select语句先在数据集运行一下,那么就得出了纪录集的所有字段,而不用自己一个个添加。

4、建立报表的参数CustomerID,设置默认值为*,和存储过程当中判断语句一致。

5。、更改数据中的语句:="exec procTest '" & Parameters!CustomerID.Value & "'"

6、基本上完成。

在演示中不知道如何按F5出现报表无法现实,但是在预览中是正常的,大概原理能明白就可以了。关于报表匿名浏览的问题网上有介绍,这里就不多说了。

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.