如何在水晶报表中指定SQL表类型输入参数?
我需要将键值列表传递给 SQL-Server 中的存储过程,然后该存储过程返回 Crystal Report 所需的值。
建议我使用表类型,而不是发送逗号分隔的列表然后解析它。因此,我将该表类型定义为简单地由整数组成:
CREATE TYPE [dbo].[SiteIdentifiers] AS TABLE
(
[SiteId] BigInt,
PRIMARY KEY ([SiteId])
)
但是,现在我需要修改我的 Crystal Report 以将其作为输入参数。 (存储过程以...开始。
CREATE PROCEDURE [dbo].[sp_SiteReport]
@SiteIds [dbo].[SiteIdentifiers] ReadOnly
AS
报表主要用ColdFusion或C#.net调用,所以我认为向表类型添加ID不会有问题。但我不知道如何定义Crystal 中的该参数的“创建新参数”向导中的类型列表非常少。
I need to pass a list of key values to a stored procedure in SQL-Server, and that stored procedure then returns back the values needed for a Crystal Report.
Rather than sending a comma separated list and then parsing that, it was suggested that I use a Table Type. So, I've defined that table type as simply made of integers:
CREATE TYPE [dbo].[SiteIdentifiers] AS TABLE
(
[SiteId] BigInt,
PRIMARY KEY ([SiteId])
)
However, now I need to modify my Crystal Report to take that as an input parameter. (The stored procedure starts with...
CREATE PROCEDURE [dbo].[sp_SiteReport]
@SiteIds [dbo].[SiteIdentifiers] ReadOnly
AS
The Reports will mostly be called with ColdFusion or C#.net, so I don't think there will be an issue in adding IDs to the table type. But I don't know how to define that parameter in Crystal. The list of Types in the Create New Parameter wizard is rahter scant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您没有以正确的方式使用 Crystal 中的参数概念。据我所知,它最适合手动输入数据(并且您试图传递多维数组,而不是它的最佳用途)。我建议:
或者
I don't think you're using the Parameter concept in Crystal the right way. To my knowledge, it's best used for manually entering data (and you're trying to pass a multi-dimensional array, not the best use of it). I recommend:
OR
据我所知,这是不可能的。 Crystal 不会从其他应用程序(例如 SQL Server)获取它无法识别的数据类型。
As far as I can tell, this is not possible. Crystal does not take data types that it doesn't recognize from other applications, such as SQL Server.
通常,通过将报表指向该过程来创建运行过程的 Crystal 报表 - 该过程所需的任何参数都会在报表中自动生成。如果您在 Crystal Reports 设计器中完成了此操作,而报表没有生成表输入参数,那么我认为您不能这样做。
作为使用逗号分隔列表的另一种替代方法,您是否考虑过:
Normally, a Crystal report that runs off a procedure is created by pointing the report at the procedure - any required parameters for the procedure are automatically generated in the report. If you have done this in the Crystal Reports designer without the report generating the table input parameter, then I don't think you can do it this way.
As another alternative to using a comma-separated list, have you considered: