水晶报表 - 传递 DateRange 参数 [英] Crystal Report - Pass DateRange Parameter

查看:24
本文介绍了水晶报表 - 传递 DateRange 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 CR 相对较新.最近一直在将许多以前通过 vbscripts 执行的旧报告转换为在 vb.net 上运行.

Relatively new to working with CR. Have lately been converting a lot of old reports that were previously executed via vbscripts to run with vb.net.

我有一份无法处理的特定报告.为了运行,它需要一个存储在名为DateRange"的参数字段中的日期范围

I have a particular report I can't get working. In order to run, it expects a date range that it stores in a parameter field called "DateRange"

在调用此报告并导出它的旧 vbscript 中,传递此日期范围参数的代码是:

In the old vbscript that called this report and exported it, the code to pass this daterange parameter was:

Set crParms = CrystalReport.ParameterFields
crParms.Item(1).AddCurrentRange CDate(StartDate), CDate(EndDate), 3

谁能帮我看看这段代码在 vb.net 中应该是什么样子?我有点困惑,因为报告中的DateRange"参数是一个变量.那么它是期待一个日期的集合还是什么?

Can anybody help me out with what this code should look like in vb.net? I'm a little confused as in the report the "DateRange" parameter is a single variable. So is it expecting a collection of dates or something?

我只是创建一个简单的控制台项目来调用报告、传递日期范围并导出报告.我已经能够找出导出报告的代码,而且效果很好.我只需要弄清楚如何将我的日期范围传递到报告中.

I'm just creating a simple console project to call the report, pass the date range, and export the report. I have been able to figure out the code to export the report, and it works great. I just need to figure out how to pass my date range into the report.

谢谢!

推荐答案

如果其他人需要帮助将两个日期从 VB.NET 传递到 Crystal 报表中的单个 DateRange 参数,这最终对我有用:

Should anyone else need help passing two dates from VB.NET to a single DateRange parameter in a Crystal report, this is what ended up working for me:

Const PARAMETER_FIELD_NAME As String = "DateRange"

Dim startDate as Date

Dim endDate as Date


<other code>


Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterRangeValue As New ParameterRangeValue


crParameterRangeValue.StartValue = startDate
crParameterRangeValue.EndValue = endDate


crParameterFieldDefinitions = cryReport.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item(PARAMETER_FIELD_NAME)
crParameterValues = crParameterFieldDefinition.CurrentValues


crParameterValues.Clear()
crParameterValues.Add(crParameterRangeValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)


<other code>

我确实发现 本教程在编写上面对我有用的代码.

I did find this tutorial to be extremely helpful in writing the code that worked for me above.

这篇关于水晶报表 - 传递 DateRange 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆