Skip to content

Change SQL string from Code

Peter Gill edited this page May 3, 2024 · 4 revisions
dotnet add package Majorsilence.Reporting.RdlViewer

In this example a rdl viewer is created and then we assign a new sql string to the dataset for the reports DataSet "DataSetNameInYourReport". Column name and data types must match the report definition.

using fyiReporting.RDL;
using fyiReporting.RdlViewer;
using fyiReporting.Data;

fyiReporting.RdlViewer.RdlViewer rdlView = new fyiReporting.RdlViewer.RdlViewer();
rdlView.SourceFile = new Uri("\\path\to\your\report.rdl");

// Column name and data types must match the report definition.
rdlView.Report.DataSets["DataSetNameInYourReport"].SetSource("SELECT CategoryID, CategoryName, Description FROM Categories where CategoryName = 'SeaFood'");

rdlView.Rebuild();

See the sample project.

Find the dataset name in the designer

The Data Set Name