Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

DataTable Find stops working in the middle of my For

Back to Forum: Tech Off
  • User profile image
    qwert231

    Ok, here's the scenerio. I load an XML file into a dataset, then take one table, and put it into a dataview, so I can sort it. I walk through that dataview, pulling records and doing what I need. Here's some of the code:

       dsDataMatch.Clear()
      Dim keys(1) As DataColumn
      Try
       dsDataMatch.ReadXml(Me._fPath)
       If Me.dsDataMatch.Tables("SubjectData").Columns.Contains("RecID") Then
        Me.IDCol = "RecID"
        keys(0) = Me.dsDataMatch.Tables("Orders").Columns("RecID")
        Me.dsDataMatch.Tables("Orders").PrimaryKey = keys
       Else
        Me.IDCol = "recNum"
        keys(0) = Me.dsDataMatch.Tables("Orders").Columns("recNum")
        Me.dsDataMatch.Tables("Orders").PrimaryKey = keys
       End If
       If Me.dsDataMatch.Relations.Contains("SubjOrders") Then Me.dsDataMatch.Relations.Remove("SubjOrders")
       Me.dsDataMatch.Relations.Add(New DataRelation("SubjOrders", Me.dsDataMatch.Tables("SubjectData").Columns(Me.IDCol), Me.dsDataMatch.Tables("Orders").Columns(Me.IDCol)))

      Catch Ex As Exception
       MsgBox(Ex.ToString)
      End Try

    ....

       If isDM Then
        dvOrders = New DataView(Me.dsDataMatch.Tables("Orders"))
       Else
        dvOrders = New DataView(Me.dtDataFile)
       End If

       If SortImageName Then
        If isDM Then
         dvOrders.Sort = "ImageName"
        Else
         dvOrders.Sort = "Image Name"
        End If
       End If

       For intRow2 = 0 To lastRow ' Each rowThis In Me.dsDataMatch.Tables("Orders").Rows
        Dim tempInt As Integer
        If isDM Then
         tempInt = dvOrders(intRow2)("OrderID")
         rowThis = Me.dsDataMatch.Tables("Orders").Rows.Find(dvOrders(intRow2)("OrderID"))
        Else
         tempInt = dvOrders(intRow2)("Record Numbe")
         rowThis = Me.dtDataFile.Rows.Find(dvOrders(intRow2)("Record Number"))
        End If
        If IsNothing(rowThis) Then
         MsgBox("Couldn't find OrderID/Record Number: " & tempInt)
        End If

    ....

    Now, this For loop works for let's say, 134 records. At 135 it stops. Here's what I saw in my watch: Generic Forum Image Basically, the dataview that I'm looking at in my for shows OrderID 769. Doing a find for that gives me Nothing. But if I go directly to that row, OrderID is 769.

    Why might this happen? I'm using VB.Net 2.0.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.