E
ECathell
Collections are really kicking me hard.
I have a class Box. It has 3 properties(Boxtype,BoxTare,BoxDescription)
I also want to make a BoxCollection object. I have tried using collectionbase and arraylist, but I can't figure out how to "make it work" the way I think it should.
Public Class BoxCollection
Inherits ArrayList
Public Sub New()
End Sub
Private mBoxNames As ArrayList
Public ReadOnly Property BoxNames() As ArrayList
Get
Return mBoxNames
End Get
End Property
Public Function getBoxNames(ByVal location As String) As BoxCollection
Dim db As dal.Database = Nothing
db = dal.DatabaseFactory.CreateDatabase(location)
Dim reader As IDataReader
Dim commandtext As String = "Select Boxtype from boxes"
reader = db.ExecuteReader(CommandType.Text, commandtext)
While reader.Read
mBoxNames.Add(reader(0))
End While
End Function
This is one of my attempts. I feel like I have failed miserably.Can anyone point me to good tutorials on collections and building them? Or should I take another avenue since its attached to a database?
I have a class Box. It has 3 properties(Boxtype,BoxTare,BoxDescription)
I also want to make a BoxCollection object. I have tried using collectionbase and arraylist, but I can't figure out how to "make it work" the way I think it should.
Public Class BoxCollection
Inherits ArrayList
Public Sub New()
End Sub
Private mBoxNames As ArrayList
Public ReadOnly Property BoxNames() As ArrayList
Get
Return mBoxNames
End Get
End Property
Public Function getBoxNames(ByVal location As String) As BoxCollection
Dim db As dal.Database = Nothing
db = dal.DatabaseFactory.CreateDatabase(location)
Dim reader As IDataReader
Dim commandtext As String = "Select Boxtype from boxes"
reader = db.ExecuteReader(CommandType.Text, commandtext)
While reader.Read
mBoxNames.Add(reader(0))
End While
End Function
This is one of my attempts. I feel like I have failed miserably.Can anyone point me to good tutorials on collections and building them? Or should I take another avenue since its attached to a database?