SqlDataSource store procedure with parameters Programming with C#

1 Answer 5 Views
.NET Core DataSource SQL Report Viewer - ASP.NET
Mina
Top achievements
Rank 1
Mina asked on 17 Nov 2025, 10:40 AM

Hi, 

I am facing an issue with Telerik Report with C# when assigning a SqlDataSource to a table programmatically in a Telerik Report. The problem occurs only when the stored procedure has parameters — the report returns no data, but it does not throw any exceptions. When the stored procedure has no parameters, everything works correctly.

Environment

  • .NET version: .net 9.0
  • Report Type: TRDP (packaged report)
  • Rendering from C# code (ReportProcessor)

Problem Description

Inside my TRDP report, I locate a Table item at runtime and assign a new SqlDataSource to it. The SqlDataSource uses:

  • A valid SQL Server connection string
  • A stored procedure name
  • A parameter (e.g. @Year)

The issue:

  • When the stored procedure has parameters, the report shows no data even though no exceptions occur.
  • When the stored procedure does NOT have parameters, everything works correctly.
  • Executing the stored procedure in SSMS using the same parameter value returns rows.

Code Example

var table1 = FindItem<Table>(report, "table1");

if (table1 != null)

{

    var dsTable = new Telerik.Reporting.SqlDataSource();

    dsTable.ConnectionString = connectionString!;

    dsTable.SelectCommand = storedProc!; // ex: "dbo.MyReportProc"

    dsTable.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;

 

    // Adding parameter

    dsTable.Parameters.Add("@Year", DbType.Int32, 2024);

 

    table1.DataSource = dsTable;

}

 

What I have already confirmed

  • Connection string is valid (works for non-parameterized SP).
  • Stored procedure name is correct and exists.
  • Parameter name matches exactly (@Year).
  • Data exists in the database for the specified parameter.
  • Removing the parameter from the SP makes the report return data normally.
  • The same logic reproduces consistently.

Question / Request

Could you please advise whether:

  1. There is a known issue when assigning a SqlDataSource with parameters programmatically?
  2. Parameter names for stored procedures require a specific format (e.g., no @ prefix)?
  3. Additional configuration is needed when binding a stored-procedure data source at runtime?
  4. There are diagnostics or logging steps to help trace how parameters are passed inside Telerik Reporting?

 

Thank you for your assistance.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 18 Nov 2025, 10:24 AM

Hi Mina,

In the Support Ticket you opened on the same issue, I gave you more details on what I tested, trying to reproduce the issue.

I will provide a summary here for the benefit of our community.

The SqlDataSource parameters set the way you do with code worked as expected and fetched the correct data in .NET Framework and in .NET 9 during my tests.

Based on the available information, I cannot reproduce the issue and state a reason for the SqlDataSource parameters not to work as expected. I suspect the parameter types may be incorrect.

Addressing your particular questions:

  • There is a known issue when assigning a SqlDataSource with parameters programmatically?

No, we are not aware of such an issue.

  • Parameter names for stored procedures require a specific format (e.g., no @ prefix)?

There is no specific format for MSSQL parameters. They may start with '@' as seen in the sample.

  • Additional configuration is needed when binding a stored-procedure data source at runtime?

No settings other than those you used.

  • There are diagnostics or logging steps to help trace how parameters are passed inside Telerik Reporting?

Please attach a Trace Listener to your application to get more details on the issue: Troubleshooting Reporting Implementation in ASP.NET Core Application.

You can also use the database server profiler to check if anything fails on the database server.

Regards,
Todor
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
.NET Core DataSource SQL Report Viewer - ASP.NET
Asked by
Mina
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or