Looping through Dataset

C

Charlie Brown

I am using the code below to loop through a dataset for reporting
stats. The problem I have is when I modify a row of data, it counts
that row 3 times the next time i run the loop. I believe it has
something to do with the way datasets keep track of changes.

For Each row As DataRow In CustomerDataSet.Tables(0).Rows
Dim dtRedeemed As DateTime
Dim intLocation As Integer
If Not row("RedeemedOn") Is DBNull.Value Then
dtRedeemed = CDate(row("RedeemedOn"))
End If
If Not row("LocationID") Is DBNull.Value Then
intLocation = CStr(row("LocationID"))
End If

If intLocation = LocationID Then
iTotal += 1
If dtRedeemed.Date = Now.Date Then
iToday += 1
End If
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top