如何在水晶报表中指定SQL表类型输入参数?

发布于 2024-09-24 19:37:37 字数 526 浏览 2 评论 0原文

我需要将键值列表传递给 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

把梦留给海 2024-10-01 19:37:37

我认为您没有以正确的方式使用 Crystal 中的参数概念。据我所知,它最适合手动输入数据(并且您试图传递多维数组,而不是它的最佳用途)。我建议:

  1. 您的第一个想法是将表格作为逗号分隔的字符串输入。
    或者
  2. 将过程的输出保存到 SQL-Server 中的临时表并导入。

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:

  1. Your first idea of feeding in the table as a comma-delimited string.
    OR
  2. Saving your procedure's output to a temporary table in the SQL-Server and importing that.
我ぃ本無心為│何有愛 2024-10-01 19:37:37

据我所知,这是不可能的。 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.

猥琐帝 2024-10-01 19:37:37

通常,通过将报表指向该过程来创建运行过程的 Crystal 报表 - 该过程所需的任何参数都会在报表中自动生成。如果您在 Crystal Reports 设计器中完成了此操作,而报表没有生成表输入参数,那么我认为您不能这样做。

作为使用逗号分隔列表的另一种替代方法,您是否考虑过:

  • 创建一个表来保存会话 ID 和输入值,
  • 在运行报告之前使用会话 ID 和所需的输入值填充该表,
  • 将会话 ID 传递给将报告作为参数,
  • 将报告中的会话 ID 作为参数传递给过程,
  • 对过程进行编码以根据会话 ID 从新表中选择输入值,并在运行报告后删除会话 ID 的条目?

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:

  • creating a table to hold session IDs and input values,
  • populating the table just prior to running the report with a session ID and the input values required,
  • passing the session ID to the report as a parameter,
  • passing the session ID from the report to the procedure as a parameter,
  • coding the procedure to select the input values from the new table based on the session ID, and removing the entries for the session ID after running the report?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文