SSRS 通过Customer Code访问Dataset
A dataset in Reporting Services is not the same type of object as an ADO.Net dataset. A report dataset is an internal object managed by the SSRS runtime (it's actually derived from a DataReader object) and not an XML structure containing datatables, etc. and cannot be passed into the report's custom code.
我们在SSRS中创建了DataSet,然后试图通过Customer Code来访问该DataSet。在一番查询之后,发现似乎没有办法直接在Customer Code中调用DataSet...
然而,Customer Code是可以访问Parameter的,而Parameter又和DataSet能够关联,于是就有了如下的方案来实现Customer Code 遍历DataSet。
1,创建DataSet,命名为Test_DataSet
创建测试用例,该DataSet有2列,分别为Id和Name
Select 1 As 'Id',1000 As 'Name' Union All
Select 2 As 'Id',2000 As 'Name'
2,创建Parameter,命名为Test_Parameter
在General页签,选择Data Type为Text,Allow multiple values为True,Hidden为True
在Availabe Values页签,选择Get values from a query,DataSet选择Test_DataSet,Value Filed选择Id,Label Field选择Name
在Default Values页签,选择Get vaules from a query,DataSet选择Test_DateSet,Value Field选择Id
在Advanced页签,选择Never refresh
3,选中Report,查看属性,在Code中输入如下Vb Code
这实现了根据输入的Id,遍历DataSet得到对应的Name的效果
Public Function GetValue(Id As Integer) As String
Dim i As Integer
i=
For i = 0 to Report.Parameters!Test_Parameter.Count() - 1
If Report.Parameters!Test_Parameter.Value(i) = Id Then
GetValue = Report.Parameters!Test_Parameter.Label(i)
Exit For
End If
Next i
End Function
4,在Report中,对应的单元格中,使用如下Expression进行调用
=Code.VerValue()
Preview Report,该单元格中显示值1000
最新文章
- SharePoint 2013 Apps TokenHelper SharePointContext OAuth Provider-Hosted App (抄袭,测试 csc.rsp 用)
- 2016";百度之星"; - 资格赛(Astar Round1)
- Yii;CodeIgniter;thinkphp学习
- MySql Windws 下自动备份脚本
- SQL TO LINQ(Linqer神器)
- 错误3 error C3859: 超过了 PCH 的虚拟内存范围;请使用“-Zm120”
- Linux基础知识之—— nohup命令使程序在后台运行的方法
- 两种局部刷新UITableView的方法的使用条件
- 《Python 学习手册4th》 第十七章 作用域
- JAVA spring 常用包作用
- android_handler(三)
- 【CC2530入门教程-01】IAR集成开发环境的建立与项目开发流程
- Helm简介及安装
- Java File mkdir() mkdirs()
- 安卓音、视频播放功能简单实现 --Android基础
- [leetcode]Minimum Depth of Binary Tree--二叉树层序遍历的应用
- intel笔记本cpu型号后缀详解(M,U,QM,MQ,HQ,XM)
- 持续集成之四:Jenkins+sonarqube
- Android中Handler的使用
- shell基础篇(九)函数