如何从Crystal Reports调用存储过程?

时间:2022-08-19 16:39:10

I have a stored procedure that takes a user ID and calculates their balance with a really simple query and returns it. I want to add this to a crystal report in my application. The only problem is, Crystal Reports wants me to set a value for the procedure, and setting a single value for it would be useless to me.

我有一个存储过程,它接受用户ID并通过一个非常简单的查询计算它们的余额并返回它。我想在我的应用程序中将其添加到水晶报告中。唯一的问题是,Crystal Reports希望我为程序设置一个值,为它设置一个值对我来说没用。

I have everything grouped by the User.ID field, and I want to use User.ID as the parameter for the query. How can I do this?

我有所有按User.ID字段分组的内容,我想使用User.ID作为查询的参数。我怎样才能做到这一点?

2 个解决方案

#1


Couple of options

几个选项

1. Create a new stored procedure that returns all of the user ID's then create a sub-report for each user linked to the main report of user IDs.

1.创建一个返回所有用户ID的新存储过程,然后为链接到用户ID主报告的每个用户创建一个子报告。

2. If you have the option, change the stored procedure to accept a value like 'All' for the username and have the stored procedure return all values when All is the value. Not 100% sure if this will work, just a brainstorming idea.

2.如果您有选项,请更改存储过程以接受用户名的“全部”值,并使存储过程在All为值时返回所有值。不是100%肯定这是否有用,只是一个头脑风暴的想法。

#2


Within your main report you can add a subreport that will use the stored procedure as a data source and the userId as a parameter.

在主报表中,您可以添加一个子报表,该子报表将使用存储过程作为数据源,并将userId用作参数。

Your main report will list all the userID you are interested in and pass each of them individually to subreport

您的主报告将列出您感兴趣的所有用户ID,并将它们分别传递给子报告

It has been quiet some time since I last worked with crystal reports so I do not remember the technical details, only the main concept

自从我上次使用水晶报告以来一直很安静,所以我不记得技术细节,只记住了主要概念

#1


Couple of options

几个选项

1. Create a new stored procedure that returns all of the user ID's then create a sub-report for each user linked to the main report of user IDs.

1.创建一个返回所有用户ID的新存储过程,然后为链接到用户ID主报告的每个用户创建一个子报告。

2. If you have the option, change the stored procedure to accept a value like 'All' for the username and have the stored procedure return all values when All is the value. Not 100% sure if this will work, just a brainstorming idea.

2.如果您有选项,请更改存储过程以接受用户名的“全部”值,并使存储过程在All为值时返回所有值。不是100%肯定这是否有用,只是一个头脑风暴的想法。

#2


Within your main report you can add a subreport that will use the stored procedure as a data source and the userId as a parameter.

在主报表中,您可以添加一个子报表,该子报表将使用存储过程作为数据源,并将userId用作参数。

Your main report will list all the userID you are interested in and pass each of them individually to subreport

您的主报告将列出您感兴趣的所有用户ID,并将它们分别传递给子报告

It has been quiet some time since I last worked with crystal reports so I do not remember the technical details, only the main concept

自从我上次使用水晶报告以来一直很安静,所以我不记得技术细节,只记住了主要概念