Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, i have web application in which i am using crystal report with subreports.The problem is that not able to load subreport "Invalid report" error at below highlighted(bold) line. Any solution for this?

C#
 ReportDocument rptDoc = new ReportDocument();
rptDoc.Subreports[(Server.MapPath("../Reports/SalesHeader.rpt"))].SetDataSource(dsHeader.Tables[0]);
rptDoc.Load(Server.MapPath("../Reports/SalesProductReport.rpt"));
 rptDoc.SetDataSource(dtproductview);           rptDoc.Subreports[Server.MapPath("../Reports/SalesFooter.rpt")].SetDataSource(dsFooter.Tables[0]);
Posted
Updated 17-Oct-12 4:00am
v2

try to put this line
rptDoc.Subreports[(Server.MapPath("../Reports/SalesHeader.rpt"))].SetDataSource(dsHeader.Tables[0]);

after this line
C#
rptDoc.Load(Server.MapPath("../Reports/SalesProductReport.rpt"));
 rptDoc.SetDataSource(dtproductview);
 
Share this answer
 
Comments
sharadpanwal 18-Oct-12 2:02am    
hi manak, after changing the code i got error "Object reference not set to an instance of an object." on same line
manak chand 18-Oct-12 2:06am    
after first line of code, check wheather report is loaded in rptDoc or it is null. one more thing you can check, wheater new instance is created of Reportdocument as rptDoc.
i have just change my code like this

C#

C#
rptDoc.Load(Server.MapPath("../Reports/SalesProductReport.rpt"));
rptDoc.SetDataSource(dtproductview);
rptDoc.Subreports[0].SetDataSource(dsHeader.Tables[0]);
rptDoc.Subreports[1].SetDataSource(dsFooter.Tables[0]);


i got it working, thanks for help!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900