简体   繁体   中英

Visual Basic: How to delete specific column while looping through DataTable rows?

I'm looping through the datatable as follows:

For Each row As DataRow In records.Rows
    If row.Item("SYS_CHANGE_OPERATION") = "I" Then

    End If
Next

When the row meets the condition of the column, I need to remove an specific column of that same row.

I know how to do it, if I want to remove a column from the whole DataTable. Code is a simple as:

myDataTable.Columns.Remove("IdKey")

Simple code, yet, I don't find an answer around Google nor SO that explain how to remove a column withing the loop of rows.

Help! Thank you!

Set cells empty:

Dim x = dt.Rows.Cast(Of DataRow).Where(Function(r) r("SYS_CHANGE_OPERATION") = "I")
x.ToList().ForEach(Sub(r) r("SYS_CHANGE_OPERATION") = Nothing)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM