Apply Row Count At Connection Level for 'View Data' & 'Preview' Report
Posted: Thu Oct 16, 2025 12:50 pm
Hello,
I'm licensed user and using Stimulsoft.Reports.Web.NetCore v2025.4.1. I need to apply the configured row limit when result is displated in View Data (new tab also) & Preview. My database has millions of records so when View Data is pressed, the app crashes. Even after applying lots of predicates for the query, there are millions of records. So anyhow limiting is required.
Below code works for Preview report (executes before StiNetCoreDesigner.PreviewReportResult from controller) but not for View Data (executes before StiNetCoreDesigner.DesignerEventResult from controller):
The same code was working till version v2022.4.5. After upgrading to v2023.1.8 or till v2025.4.1, it doesn't. As per my detailed analysis, I have noticed from v2023.1.8 (https://www.stimulsoft.com/en/changes/r ... t/2023.1.8) there is change in SqlConnection. “The MS SQL Data Adapter System.Data.SqlClient has been replaced with a more functional Microsoft.Data.SqlClient for all .NET Standard 2.1 / .NET Core 3.1 / .NET 5 / .NET 6 components.” I believe this is true as when ran SQL Profiler:
- v2022.4.5: SPID is same for SET ROWCOUNT X; & for actual query, hence both executes in the same batch, Stimulsoft does not open new connection per queries. Works.
- v2023.1.8 till v2025.4.1: SPID is DIFFERENT for SET ROWCOUNT X; & for actual query, hence both executes in the same batch, Stimulsoft OPENS new connection per queries. DOES NOT WORK.
I have tried below approaches which DIDN'T WORK:
1. Updating SqlCommand by replacing SELECT with SELECT TOP: Just defaults data source query with SELECT TOP. When removed, does not apply row limit.
2. Tried RowNumer() > X filter on data source
3. Create custom data adapter
4. Updating SqlCommand for each data source on the report's dictionary by appending SET ROWCOUNT X;.
5. Creating a RowLimitConnectionWrapper & RowLimitCommandWrapper. It just defaults data source query in Designer with SET ROWCOUNT X; statement. When removed, does not apply row limit.
6. Creating custom function to limit the rows
7. Setting StiOptions.Engine.Data.MaxDataRowsForPreview
8. Setting MaxDataRowsOfDashboardElementInDesigner
9. report.Dictionary.DataSources.Items["YourDataSourceName"].MaxRows = maxRows;
10. stiReport.Dictionary.DataSources.ToList().ForEach(ds => ds.MaxDataRowsToProcess = 1000);- Not working as no such property
May I have some solution for this?
Thank you in Advance!
I'm licensed user and using Stimulsoft.Reports.Web.NetCore v2025.4.1. I need to apply the configured row limit when result is displated in View Data (new tab also) & Preview. My database has millions of records so when View Data is pressed, the app crashes. Even after applying lots of predicates for the query, there are millions of records. So anyhow limiting is required.
Below code works for Preview report (executes before StiNetCoreDesigner.PreviewReportResult from controller) but not for View Data (executes before StiNetCoreDesigner.DesignerEventResult from controller):
Code: Select all
var stiSqlConnectionDatabase = (StiSqlDatabase)stiReport.Dictionary.Databases["Connection"];
stiSqlConnectionDatabase.ConnectionString = _theService.GetConnectionString(userDetails);
stiSqlConnectionDatabase.Connected += (_, _) =>
{
try
{
var sqlConnection = (SqlConnection)stiReport.DataStore[0].Data;
sqlConnection.Open();
using var sqlCommand = sqlConnection.CreateCommand();
sqlCommand.CommandText = $"SET ROWCOUNT {_configurationService.GetOptions<StimulsoftOptions>(userDetails).SqlRowCount};";
sqlCommand.ExecuteNonQuery();
}
catch (Exception)
{
// Ignore
}
};
- v2022.4.5: SPID is same for SET ROWCOUNT X; & for actual query, hence both executes in the same batch, Stimulsoft does not open new connection per queries. Works.
- v2023.1.8 till v2025.4.1: SPID is DIFFERENT for SET ROWCOUNT X; & for actual query, hence both executes in the same batch, Stimulsoft OPENS new connection per queries. DOES NOT WORK.
I have tried below approaches which DIDN'T WORK:
1. Updating SqlCommand by replacing SELECT with SELECT TOP: Just defaults data source query with SELECT TOP. When removed, does not apply row limit.
2. Tried RowNumer() > X filter on data source
3. Create custom data adapter
4. Updating SqlCommand for each data source on the report's dictionary by appending SET ROWCOUNT X;.
5. Creating a RowLimitConnectionWrapper & RowLimitCommandWrapper. It just defaults data source query in Designer with SET ROWCOUNT X; statement. When removed, does not apply row limit.
6. Creating custom function to limit the rows
7. Setting StiOptions.Engine.Data.MaxDataRowsForPreview
8. Setting MaxDataRowsOfDashboardElementInDesigner
9. report.Dictionary.DataSources.Items["YourDataSourceName"].MaxRows = maxRows;
10. stiReport.Dictionary.DataSources.ToList().ForEach(ds => ds.MaxDataRowsToProcess = 1000);- Not working as no such property
May I have some solution for this?
Thank you in Advance!