Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: .Net objects as datasource, problem linking data Post Reply Post New Topic
Author Message
Gotham
Newbie
Newbie
Avatar

Joined: 08 Dec 2008
Location: Sweden
Online Status: Offline
Posts: 1
Quote Gotham Replybullet 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.

Order
 - OrderNr (primary key)
 - CustomerName

OrderItem
 - OrderNr (foreign key)
 - ProductName
 - Qty

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."

Environment:
* VS.NET 2008
* Crystal Reports for VS.NET 2008
* ReportViewer (WinForms)

Kind regards
/ Richard
IP IP Logged
jamshid.gh
Newbie
Newbie
Avatar

Joined: 07 Jul 2011
Location: Iran
Online Status: Offline
Posts: 1
Quote jamshid.gh Replybullet Posted: 07 Jul 2011 at 9:10pm
Hi,
you must Set Data Source for all Objects.
like:
CrystalReportObject.Database.tables[0].SetDataSource(order);
CrystalReportObject.Database.tables[1].SetDataSource(orderItems);



Edited by jamshid.gh - 07 Jul 2011 at 9:10pm
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.031 seconds.