Need Help Updating Records VS2005

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!
 
J

Justin

DOH!

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

Problem solved!
 

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