troubleshooting Question

Refresh Data Collection Class VB.Net 2015

Avatar of p-plater
p-platerFlag for Australia asked on
Visual Basic.NET.NET Programming
4 Comments1 Solution226 ViewsLast Modified:
I Have the Following classes.
The first one is an Order Class and the Second one is a Collection of Orders.

I declare an Instance of this Collection Class.
Dim orderCollection = New ProductionOrderCollection

That works Fine - But I need to Refresh the Collection to get Updated Data from the Database.

Is there a Way to Refresh the Current Instance of the Collection Class or do I have to Remove the Instance and Create a New one?

orderCollection = nothing
orderCollection = New ProductionOrderCollection

Does Removing the Instance and Creating a New Instance waste Memory?

Order Class
Public Class ProductionOrder
    Public Property SalesOrderID As Integer
    Public Property CustomerName As String
    Public Property DespatchMethod As String
End Class

Order Collection Class
Public Class ProductionOrderCollection

    Inherits List(Of ProductionOrder)

    Public Sub New()
        'Declare the Handled Exception Collection
        Dim handledException = CustomErrorCollection.GetCustomErrorCollection

        'Declare Data Reader
        Dim drd As DbDataReader

		'Get Data from Data DLL
		drd = ProductionData.Orders

		While drd.Read
			Dim order As New ProductionOrder
			order.SalesOrderID = drd.GetInt32(0)
			order.CustomerName = drd.GetString(1)
			order.DespatchMethod = drd.GetString(2)
			Me.Add(order)
		End While

    End Sub
End Class
ASKER CERTIFIED SOLUTION
Karrtik Iyer
Software Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros