Check empty datasource

Stimulsoft Reports.WEB discussion
Post Reply
smart+
Posts: 26
Joined: Thu Sep 09, 2010 4:53 pm
Location: Croatia

Check empty datasource

Post by smart+ »

Hello,

After I rendered report in my ASP.NET web application, I want check if datasource is empty or not (datasource have rows or not).
If data exist I want proceed with generating PDF, and if is empty I don't want do this.

Does exist way for checking if is empty data before I generate PDF?

I using following syntax in my web application:
using (StiReport report = new StiReport())
{
report.Load(HttpContext.Current.Server.MapPath("../Reports/CourseWWorks.mrt"));
report.Dictionary.Variables["idcourse"].ValueObject = 55;
report.Dictionary.Variables["iduser"].ValueObject = 100;

Stimulsoft.Report.Dictionary.StiSqlDatabase sqlDB = (Stimulsoft.Report.Dictionary.StiSqlDatabase)report.Dictionary.Databases[0];
sqlDB.ConnectionString = DataLayer.GetConnectionString;

report.Render(false);

/*
This is place where I want make checking !
*/

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(CurrentPage, report, true);
}
Best regards,
Sasa
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Check empty datasource

Post by Ivan »

Hello,

Please do the following:
- add to the report dictionary the new variable "counter", type of int.
- add to the BeginRender event of the DataBand, which use your datasource, the following code: counter = Categories.Count;
- after the report rendering please use the following code: int rowsCount = (int)rep["counter"];

Thank you.
smart+
Posts: 26
Joined: Thu Sep 09, 2010 4:53 pm
Location: Croatia

Check empty datasource

Post by smart+ »

It works.

Thanx.
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Check empty datasource

Post by Andrew »

Great!

Always glad to help you!

Thank you.
mirzaei2003
Posts: 6
Joined: Mon Mar 07, 2011 7:17 am

Check empty datasource

Post by mirzaei2003 »

HELLO
my page has not databand.
why this code is not working?
report1.Dictionary.DataSources["datasourcename"].IsEmpty
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Check empty datasource

Post by Alex K. »

Hello,

Please chech the following code:

Code: Select all

report1.CompiledReport.DataSources["datasourcename"].IsEmpty 
Thank you.
Post Reply