Avatar of GRChandrashekar
GRChandrashekarFlag for India

asked on 

Crystal Report - Sub report

I am trying to pass dataset to subreport in crystal report. Last line of this code gives error object reference error

if (string.IsNullOrEmpty(Convert.ToString(ds)) || ds.Tables[0].Rows.Count == 0)
                {
                    GlobalFormValidations.ShowInformationMsgBox("There Is No Report To Show...");
                    return;
                }

                var DocReport = new ReportDocument();
                var reportPath = Application.StartupPath + "\\Reports\\" + fileName + ".rpt";
                DocReport.Load(reportPath);
               
                DocReport.SetDataSource(ds);
                DocReport.OpenSubreport("rptBanquetBalanceReport.rpt").SetDataSource(ds.Tables[1]);
Crystal Reports

Avatar of undefined
Last Comment
msd1305
Avatar of msd1305
msd1305
Flag of United Arab Emirates image

this condition

if (string.IsNullOrEmpty(Convert.ToString(ds)) || ds.Tables[0].Rows.Count == 0)

checks whether ds.tables[1] has records or not but while setting the datasource of the sub report you are using ds.Tables[0].

So there is a possibility that ds.Tables[0] is empty. Please verify.
ASKER CERTIFIED SOLUTION
Avatar of msd1305
msd1305
Flag of United Arab Emirates image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Crystal Reports
Crystal Reports

Crystal Reports is a business intelligence application from SAP SE. It is used to graphically design data connections and report layouts from a wide range of data sources including Excel spreadsheets, Oracle, SQL Server databases and Access databases, BusinessObjects Enterprise business views, and local file-system information. Report designers can place fields from these sources on the report design surface, and can also deploy them in custom formulas (using either BASIC or Crystal's own syntax), which are then placed on the design surface. Crystal Reports also supports subreports, graphing, and a limited amount of GIS functionality.

36K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo