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:
- There is a known issue when assigning a
SqlDataSourcewith parameters programmatically? - Parameter names for stored procedures require a specific format (e.g., no
@prefix)? - Additional configuration is needed when binding a stored-procedure data source at runtime?
- There are diagnostics or logging steps to help trace how parameters are passed inside Telerik Reporting?
Thank you for your assistance.
