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

查看:213
本文介绍了Crystal报表 - 传递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中,代码传递此daterange参数是:

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.

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

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