SQL Server Run a stored procedure with parameters in stimulsoft report

n9vozmp4  于 2023-06-04  发布在  其他
关注(0)|答案(1)|浏览(191)

I am trying to display a report that is generated by executing a stored procedure. The student table is defined as follows:

The stored procedure is defined in the database like this:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[GetStudentInfo]
    @StudentName NVARCHAR(50)
AS
BEGIN
    SELECT * 
    FROM Students 
    WHERE Students.Name = @StudentName
END

The data source has been defined accordingly, and a variable has been set to pass as an argument to the stored procedure.

EXEC GetStudentInfo @StudentName

However, it appears that the variable StudentName is not being properly passed to the stored procedure, causing it to not work correctly.

The preview tab:

And result in SQL Server profiler:

declare @p1 int
set @p1=12
exec sp_prepexec @p1 output,N'@StudentName varchar(50)',N'EXEC GetStudentInfo @StudentName

',@StudentName=NULL
select @p1
2mbi3lxu

2mbi3lxu1#

I was able to retrieve a report from a stored procedure using Stimulsoft by defining a select query and adding a variable to capture user input. Here's an example of how I achieved this:

USE [Student]
EXEC [dbo].[GetStudentInfo] @StudentName

In this case, @StudentName is the variable that captures the user input."

相关问题