Skip to Content
0
Former Member
Dec 04, 2008 at 08:52 PM

Using multiple object collections for a report

27 Views

I followed the tutorials here:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialsdataobjectsintroduction.htm

And I was able to make and display a report without incident (I'm doing this in VS 2008 in a winForm app, but I took the thrust of this tutorial and made it work). However I'm running into a problem trying to go beyond this tutorial.

I want to add a related object. So I created a StockTrade class that takes a stock symbol (string), timestamp, price, and quantity. I want to group on the symbol string and show some transactions. In the designer this appears to work in a straightforward way. The problem arises when I try to populate the datasets at runtime. Here's the code I'm using (the commented out stuff is the first report that works well):

//AssetListReport alr = new AssetListReport();

//alr.SetDataSource(Stock.GetSomeStocks());

//crystalReportViewer1.ReportSource = alr;

MoreComplicatedReport mcr = new MoreComplicatedReport();

//I've tried a few variations of the following couple of lines of code.

mcr.SetDataSource(Stock.GetSomeStocks());

mcr.SetDataSource(StockTrade.GetTrades());

crystalReportViewer1.ReportSource = mcr;

The report itself uses fields from both StockTrades objects and Stock objects. Any thoughts? It's obviously not production code, so I could zip the solution up if that would help.