Page 1 of 1

Check empty datasource

Posted: Wed May 04, 2011 6:09 am
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

Check empty datasource

Posted: Sat May 07, 2011 12:09 pm
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.

Check empty datasource

Posted: Tue May 10, 2011 6:21 am
by smart+
It works.

Thanx.

Check empty datasource

Posted: Tue May 10, 2011 10:13 pm
by Andrew
Great!

Always glad to help you!

Thank you.

Check empty datasource

Posted: Thu Jul 07, 2011 4:07 am
by mirzaei2003
HELLO
my page has not databand.
why this code is not working?
report1.Dictionary.DataSources["datasourcename"].IsEmpty

Check empty datasource

Posted: Fri Jul 08, 2011 6:13 am
by Alex K.
Hello,

Please chech the following code:

Code: Select all

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