none
error BC30367 class datatable cannot be indexed..... RRS feed

  • Question

  • Hi, just beginning with vb.net so bare with me :)

    I am currently working with some else code and try to figure out how to do this. I need to loop thru a datatable to be able to update some record, and quite frankly. I am not sure if this the proper approach since I use to code in SQL instead. The goal hese is to update a column based on a counter to make sure the sequence is good. This is what I have so far and the error is on the line dt!COMM_ID = iCntRow2

    the dt is declare as follow:  Dim dt As DataTable = ds.Tables(0)
    this is the code so far:

            dtNew = dt.Clone
            iRowCount = 0
            Dim iCntRow As Integer = 0
            Dim iCntRow2 As Integer = 0
            For Each dr As DataRow In dtNew.Rows
                iRowCount += 1

                previousSUPPLIER_ID = dr!SUPPLIER_ID
                previousCOMM_ID = dr!COMM_ID
                previousMETHOD_ID = dr!METHOD_ID

                ' to set comm id if need be
                For Each dr2 As DataRow In dt.Rows
                    iCntRow = 1
                    If dr2!SUPPLIER_ID = previousSUPPLIER_ID Then

                        Do Until dr2!SUPPLIER_ID <> previousSUPPLIER_ID
                            iCntRow2 = +1
                            dt!COMM_ID = iCntRow2
                        Loop
                    End If
                Next

            Next

    Just realise that the dtNew = dt.Clone does not work too 

    thanks for the help


    • Edited by AlBilly2 Tuesday, November 28, 2017 4:00 PM
    Tuesday, November 28, 2017 3:54 PM

All replies