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

最新文章

  1. SharePoint 2013 Apps TokenHelper SharePointContext OAuth Provider-Hosted App (抄袭,测试 csc.rsp 用)
  2. 2016"百度之星" - 资格赛(Astar Round1)
  3. Yii;CodeIgniter;thinkphp学习
  4. MySql Windws 下自动备份脚本
  5. SQL TO LINQ(Linqer神器)
  6. 错误3 error C3859: 超过了 PCH 的虚拟内存范围;请使用“-Zm120”
  7. Linux基础知识之—— nohup命令使程序在后台运行的方法
  8. 两种局部刷新UITableView的方法的使用条件
  9. 《Python 学习手册4th》 第十七章 作用域
  10. JAVA spring 常用包作用
  11. android_handler(三)
  12. 【CC2530入门教程-01】IAR集成开发环境的建立与项目开发流程
  13. Helm简介及安装
  14. Java File mkdir() mkdirs()
  15. 安卓音、视频播放功能简单实现 --Android基础
  16. [leetcode]Minimum Depth of Binary Tree--二叉树层序遍历的应用
  17. intel笔记本cpu型号后缀详解(M,U,QM,MQ,HQ,XM)
  18. 持续集成之四:Jenkins+sonarqube
  19. Android中Handler的使用
  20. shell基础篇(九)函数

热门文章

  1. 达梦数据库(DaMeng)如何删除IDENTITY自增属性字段
  2. [转]什么是VUE?为什么用VUE?
  3. OCP新题库,052新加的考题及答案整理-24题
  4. L365
  5. [To Selina] 《撒野》读后感
  6. VUE随笔-20181020
  7. uC/OS-II 函数之任务相关函数
  8. 容器化VS微服务
  9. session和cookie的知识总结
  10. Angular material mat-icon 资源参考_Editor