[RESOLVED] confused now ...
:confused:
Hi, this code below adds records to the collection as commented by the developer (not me), but how come not all fields are saved in the array but then those fields which are not saved can be retrieved??? :confused:
Please help, see comments with " This is adding to collection base ..."
Code:
Public Class NewMsgText
Public Txt As String
Public HtmTxt As String
End Class
Public Class RecordDefinition
Public WarnCode As String = ""
Public WarnDesc As String = ""
Public WarnType As String = ""
Public NewHdr As New NewMsgText()
Public NewFtr As New NewMsgText()
End Class
<Serializable()> _
Public Class WarningAdvisor
Inherits CollectionBase
Public Sub New()
End Sub
Public Sub Add(ByVal _newItem As RecordDefinition)
list.Add(_newItem)
End Sub
Public Function Add(ByVal xCode As String, ByVal xDescr As String, ByVal xType As String) As RecordDefinition
Dim _thisItem As New RecordDefinition()
With _thisItem
.WarnCode = xCode
.WarnDesc = xDescr
.WarnType = xType
End With
Add(_thisItem)
Return _thisItem
End Function
<XmlElement(ElementName:="Items")> _
Default Public Overridable ReadOnly Property Item(ByVal index As Integer) As RecordDefinition
Get
Return CType(Me.List(index), RecordDefinition)
End Get
End Property
End Class
Public Class Project Class
Public oWarning As New WarningAdvisor()
Dim dsCode As String
Dim dsDescr As String
Dim dsHeadText As String
Dim dsHeadHTML As String
Dim dsFootText As String
Dim dsFootHTML As String
Dim dsType As String
Dim oReader As SqlDataReader
Dim myRecords As RecordDefinition()
oReader = oCommand.ExecuteReader()
‘oReader HAVE 10 ROWS WITH 7 COLUMNS here
While oReader.Read()
dsCode = "" & oReader("Code")
dsDescr = "" & oReader("Descrip")
dsType = "" & oReader("Type")
dsHeadText = "" & oReader("TextHead")
dsHeadHTML = "" & oReader("HTMLHead")
dsFootText = "" & oReader("TextFoot")
dsFootHTML = "" & oReader("HTMLfoot")
‘THIS IS ADDING TO COLLECTION BASE, BUT WHY ONLY 3 FIELDS???
myRecords = oWarning.Add(dsCode, dsDescr, dsType)
With myRecords.NewHdr
.Txt = dsHeadText
.HtmTxt = dsHeadHTML
End With
With myRecords.NewFtr
.Txt = dsFootText
.HtmTxt = dsFootHTML
End With
End While
End Class