Question How to load value from DataSet to class?

raysefo

Well-known member
Joined
Jul 21, 2010
Messages
207
Programming Experience
Beginner
Hi,

I have a sample XML as follows:
VB.NET:
<Odds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Event ID="1" Description="a" Status="Open">
    <Outcome ID="0" Description="Final 1">1.50</Outcome>
    <Outcome ID="1" Description="Final 2">4.50</Outcome>
    <Outcome ID="2" Description="Final 3">2.50</Outcome>
  </Event>
    <Event ID="2" Description="b" Status="Open">
    <Outcome ID="3" Description="Final 3">1.11</Outcome>
    <Outcome ID="4" Description="Final 4">4.44</Outcome>
    <Outcome ID="5" Description="Final 5">2.55</Outcome>
  </Event>
</Odds>
I would like to load those data in a dataset but i want them as they appear.
For event 1 iwould like to have Outcome 0,1,2 and for event 2 there should be outcome 3,4,5. Any help would be great.

Thanks in advance.

Here is a sample code:
...
VB.NET:
Dim tbl1 As DataTable = quoteDataSet.Tables("Outcome")
            Dim lOdds As forwardLiveOdds = New forwardLiveOdds()
            Dim dsLOdds As DataSetLiveOdds = New DataSetLiveOdds()
 
            Dim evnts As [Event] = New [Event]()
 
            Dim tbl As DataTable = quoteDataSet.Tables("Event")
 
            ReDim dsLOdds.eventArray(tbl.Rows.Count)
            Dim i As Integer = 0
            Do While (i < tbl.Rows.Count)
 
                evnts = New [Event]()
                Dim myRow As DataRow = tbl.Rows(i)
                Dim eventID As String = myRow("ID")
                Dim eventDescription As String = myRow("Description")
                Dim eventStatus As String = myRow("Status")
 
                With evnts
                    .eventDescription = myRow("Description")
                    .eventId = myRow("ID")
                    .eventStatus = myRow("Status")
                End With
                dsLOdds.eventArray(i) = evnts
                i = (i + 1)
                ReDim evnts.outcomeArray(tbl1.Rows.Count)
            Loop
 
 
            Dim k As Integer = 0
            Do While (k < tbl1.Rows.Count)
                Dim out As Outcome = New Outcome()
 
                Dim myRow As DataRow = tbl1.Rows(k)
                Dim outID As String = myRow("ID")
                Dim outDescription As String = myRow("Description")
                Dim outcome As String = myRow(2)
 
                With out
                    .outcomeDescription = myRow("Description")
                    .outcomeId = myRow("ID")
                    .outcomeOdd = myRow(2)
                End With
                evnts.outcomeArray(k) = out
                k = (k + 1)
            Loop
 
            With lOdds
                .dsSetLiveOdds = dsLOdds
                .sDrawNumber = "1"
                .sOddsRevision = "2"
            End With
 
Last edited by a moderator:
Back
Top