Joined: 08 Dec 2008
Location: Sweden
Online Status: Offline
Posts: 1
Topic: .Net objects as datasource, problem linking data Posted: 08 Dec 2008 at 2:33pm
Hi all!
I have a little problem using .NET objects as a datasource for a report.
I want to be able to output an ordinary invoice with an order-head and order-items. The head contains information about the customer, deliveryaddresses and such. The order items are a collection of products bought by the related customer. And a summary at the bottom of the report.
I've created and successfully deployed a working version of the report using a .NET DataSet (XSD with tables Orders and OrderItems linked in it) but I want to do the same using .NET objects (custom classes and collections).
Preps: I've started from scratch with the report and created the classes Order and OrderItem containing the relevant properties.
Report design: I'm able to import the objects (Order and OrderItem) into the report and link them together (not sure that I'm doing it right though). I've dragged some Order-properties to the Page Header, and some OrderItems-properties to a Details section. I've tried a couple of group-settings but I'm not sure I'm setting this up right either. Removed for now.
Runtime: I create an instance of Order and set the values, then create an number of instances of OrderItem and set the values accordingly (OrderNr=same). Then I wrap the Order in an ArrayList and call SetDataSource on the report. Next I wrap the instances of OrderItems in an ArrayList and call SetDataSource directly after the first. Is this ok?
Result: Based on what data I add I can see the Order-data in the Head. But never any OrderItems an certainly not both at the same time. What am I doing wrong? How does one go about and use .NET Objects as datasource in the way I want?
Sidenote: When I close the Database Expert I get the following message: "More than one datasource ... has been used in this report. Please make sure that no SQL Expression is added and no server-side group-by is performed."
Hi,
you must Set Data Source for all Objects.
like:
CrystalReportObject.Database.tables[0].SetDataSource(order);
CrystalReportObject.Database.tables[1].SetDataSource(orderItems);
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum