Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i have an idea of call crystal report using stored proc
now i want to call subreport how to do this task?

iam created subreport and link to mainreport.
iam using datadinding source for connect to database.
So how to call subreport in code

my subreport name is SubReportMurchantAct.rpt
any body modify my code or give example...........
Give me some example code to call subreport.plz...

So how to call subreport in code
any body modify my code or give example...........

my code is to call main crystal report


C#
IDBManager dbManager = new DBManager(DataProvider.SqlServer);
                dbManager.ConnectionString = ConfigurationSettings.AppSettings["SQLCN"].ToString();
                dbManager.Open();
                dbManager.CreateParameters(1);
                dbManager.AddParameters(0, "@Trandate", dateTimePicker1.Value.Date);             
                ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_MerchantActivityByDateRangeRpt");
                MerchantActivityCrpt obj = new MerchantActivityCrpt();
                obj.SetDataSource(ds.Tables[0]);
                crystalReportViewer1.ReportSource = obj;
Posted
Updated 25-Aug-11 7:36am
v5

Have a look Please


C#
MerchantActivityCrpt obj = new MerchantActivityCrpt();
obj.SetDataSource(ds.Tables[0]);              obj.OpenSubreport("SubReportMurchantAct.rpt").SetDataSource(DTSubreport);                
crystalReportViewer1.ReportSource = obj;



DTSubreport is the Datasource of Sub report. In my case this is a Datable
 
Share this answer
 
Comments
Md. Rashim Uddin 8-Sep-11 2:13am    
Did u try with that??
a.ashraf 15-Jan-14 0:25am    
Thank you Mr. Rashim, your working.
a.ashraf 15-Jan-14 0:25am    
Its working.
I have the same scenario but my main report has no tables. I mean my main report is blank report. can u configure your code to have my subreport is displaying in the main blank report?

I have this thread to make you understand my issue:

http://stackoverflow.com/questions/23237494/how-to-select-rows-from-two-time-ranges-to-crystal-report/23261027#23261027
 
Share this answer
 

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