-
Editting a datatable
I've got a datatable and I want to loop through and edit the value of a single cell in each row. How do I go about doing that? I've tried the following, but it hasn't worked:
Code:
Dim i, j, iSum As Integer
For i = 0 To dt.Rows.Count - 1
dt.Rows(i).BeginEdit()
If i = 0 Then
dt.Rows(i).Item(6) = CInt(dt.Rows(i).Item(5)).ToString
Else
For j = 0 To i
iSum += CInt(dt.Rows(i).Item(5))
Next
dt.Rows(i).Item(6) = iSum.ToString
End If
dt.Rows(i).EndEdit()
dt.Rows(i).AcceptChanges()
Next
dt.AcceptChanges()
Any thoughts?
-
Re: Editting a datatable
Just glancing over the code, I don't see anything wrong. You say it doesn't work. What happens or doesn't happen that makes you say that?
Is the datatype for item(6) String?