Solved

Crystal Report - Sub report

Posted on 2010-11-11
2
385 Views
Last Modified: 2012-05-10
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]);
0
Comment
Question by:GRChandrashekar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 4

Expert Comment

by:msd1305
ID: 34113123
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.
0
 
LVL 4

Accepted Solution

by:
msd1305 earned 500 total points
ID: 34113136
------------------my mistake in above. I meant this --------------
this condition

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

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

So there is a possibility that ds.Tables[1] is empty. Please verify.
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question