CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    141

    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?

  2. #2
    Join Date
    Sep 2004
    Posts
    65

    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
  •  





Click Here to Expand Forum to Full Width

Featured