Why are If statements in SQL being run even when false?

1 Answer 87 Views
DataSource SQL
Bryan
Top achievements
Rank 1
Bryan asked on 10 May 2023, 02:28 PM

We have a stored procedure that is supposed to run other stored procedures based on a parameter that gets set by the first stored procedure. However, while everything works fine in the Microsoft SQL Server Management Studio, when the stored procedure is run through the report, the very first if statement is run instead of the correct if statement.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 15 May 2023, 10:33 AM

Hello Bryan,

Generally, the Reporting engine doesn't know anything about the Stored Procedures and is not responsible for executing them. The entire process of connecting to the database and executing the query or Stored Procedure is controlled by the data provider specified in the corresponding SqlDataSource component. Our code passes the connection string, parameters, and query/Stored Procedure name, and leaves the rest to the data provider. The default one is 'System.Data.SqlClient'.

Can you elaborate on the workflow? How do you pass the parameter values between the Stored Procedures?

If you use temp tables, you may find useful also the KB article Configuring Stored Procedure with Temporary Tables.

Regards,
Todor
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
DataSource SQL
Asked by
Bryan
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or