Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using two subreports in Crystal Reports. I am using following coding for set datasource for the subreport. The main report will come. But the subreport is not displaying. Please anybody help me.

C#
rptdoc.SetDataSource(ds.Tables[0]);
rptdoc.Subreports[0].SetDataSource(ds2.Tables[0]);
rptdoc.Subreports[1].SetDataSource(ds3.Tables[0]);


And also I tried this following code, the error displays "the object reference is not to an instance of an object"

rptdoc.OpenSubreport("SALESTRANSACTION").SetDataSource(ds2);
rptdoc.OpenSubreport("RECEIPTTRANSACTION").SetDataSource(ds2);
Posted

1 solution

It seems that , you are using a null object? have you debugged your code? In which line this exception is generated?
 
Share this answer
 
Comments
devausha 19-Apr-12 1:11am    
rptdoc.opensubreport("SALESTRANSACTION").setdatasource(ds2)
Sebastian T Xavier 19-Apr-12 2:20am    
do you have a subreport called SALESTRANSACTION?
please check whether ds2 is null
devausha 21-Apr-12 1:41am    
Thank you Mr.Sebastian, your guessing is correct. My query has problem.

I am using Top and max function for get five records by date in my query. But there are in database only three records has available. So it is not display,
Sebastian T Xavier 23-Apr-12 8:06am    
good to know that the tips helped you and you have figured it yourself.

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