Print Page | Close Window

Using .net object as data source.

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10243
Printed Date: 03 May 2024 at 3:56pm


Topic: Using .net object as data source.
Posted By: rpuelma
Subject: Using .net object as data source.
Date Posted: 14 Jun 2010 at 3:46am
Hello,
 
I hope I'm posting this problem in the right forum. I'm coding with VB.net, trying to create a Crystal Report (CR) from a class object.
 
I'm trying to create an order confirmation report with CR. The data is stored into a class object of type OrderItem. An order item has, beside order specific data, a list of LineItem. A line item has, beside order line specific data, a list of SubLineItem. Sub lines have only sub line specific data.
 
Ex.
 
Class OrderItem
 
Private OrderNumber As String
Private OrderLines As List(of LineItem)
 
End Class
 
Class LineItem
 
Private LineNumber As String
Private SubLines As List(of SubLineItem)
 
End Class
 
Class SubLineItem
 
Private SubLineNumber As String
 
End Class
 
First I add a CR-item to my project and set the data source to the .Net Object of OrderItem. Here I encounter the first problem, I cannot access the variable containing the list of line items. Why is that? I read somewhere that the class OrderItem should inherit from CollectionBase and I have added that code but I still cannot access the variable. I have also tried to add the LineItem-class separately but then I get an error telling me that I have multiple data sources.
 
My second problem is related to the creation of a specific PDF from the CR. So far I only got the following code and dont know what is missing:
 
Dim myReport As New ReportDocument

myReport.Load("C:\OrderConfirmationReport.rpt")

myReport.SetDataSource(myOrder)

Please help me with my problems:
 
  • How do I access my variable containing my list of LineItems (and hopefully the list of SubLineItems in the LineItems)?
  • What code is missing to create a pdf of the order (myOrder) I'm setting as data source.



Print Page | Close Window