Working with ADO.NET Datasets and .NET Objects using Crystal Reports and ASP.NET 2.0 - .NET objects as data sources to Crystal Reports: adding an entity class
(Page 4 of 6 )
In previous sections, a strongly typed dataset is created (using Visual Studio Designer) and finally assigned as the data source to Crystal Reports. Now, we will start working on only custom classes (acting as .NET Objects) and assign them as a data source to Crystal Reports.
Close the previous project and create a new website. Using the "Solution Explorer," add a new class named "Order.vb." This class simply works as an entity class holding a single row of the Orders table. For our demonstration, I took only four fields into consideration. The code for the "Order" class is as follows:
Imports Microsoft.VisualBasic
Public Class Order
Private _OrderID As Int32
Private _OrderDate As Date
Private _CustomerID As String
Private _EmployeeID As String
Public Property OrderID() As Int32
Get
Return _OrderID
End Get
Set(ByVal value As Int32)
_OrderID = value
End Set
End Property
Public Property OrderDate() As Date
Get
Return _OrderDate
End Get
Set(ByVal value As Date)
_OrderDate = value
End Set
End Property
Public Property CustomerID() As String
Get
Return _CustomerID
End Get
Set(ByVal value As String)
_CustomerID = value
End Set
End Property
Public Property EmployeeID() As String
Get
Return _EmployeeID
End Get
Set(ByVal value As String)
_EmployeeID = value
End Set
End Property
Public Sub New(ByVal oID As String, ByVal oDate As Date, ByVal oCustomerID As String, ByVal oEmployeeID As String)
_OrderID = oID
_OrderDate = oDate
_CustomerID = oCustomerID
_EmployeeID = oEmployeeID
End Sub
End Class
Next: .NET objects as data sources to Crystal Reports: adding a collection class >>
More ASP.NET Articles
More By Jagadish Chaterjee