|
-
August 2nd, 2007, 09:45 AM
#1
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?
-
August 6th, 2007, 10:25 AM
#2
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|