Need Help Updating Records VS2005

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

I'm looping through my dataset and when I find a match I need to update a
second field. However with this code ONLY the last record in the entire
set/table is updated with ALL the records data:

For Each dr As DataRow In dsTags.Tables(0).Rows
If dr("TagID") = tags(i).TagID Then
TagCheck = True
drTags("Count") = drTags("Count") + tags(i).ReadCount
dsTags.Tables(0).AcceptChanges()
End If
Next

For example, each read of a tag will give me a count of 1 or 2. Usually
just 1. So I should see each records tags count go up by 1 or 2. Instead I
see the last records tag count go up by 30 (of which I'm testing 21 tags).

So ultimately, the last record is getting all the counts itself. I figured
with each loop the value of dr("TagID") is maintained. How can I update
this field then start over? Shouldn't dr("TagID") be the value of each
individual record?

Thanks for any insight!
 
DOH!

I stared at my code long enough to see I was using drtags(Count") instead of
dr(Count").

Problem solved!
 
Back
Top