How to remove last row from the query

Dt.Asenumerable.ToList.For each(Sub(row)
row(2)=23
End sub)

I dont want the last row of the datatable to be updated with the value 23

Dt.take(Dt.rows.count-1).copytodatatable

Hope this helps

Hi,

Can you try the following?

Dt.Asenumerable.Take(Dt.Rows.Count-1).ToList.ForEach(Sub(row)
row(2)=23
End Sub)

Regards,

When working within Project Compatibility we can shorten

YourDataTableVar.AsEnumerable().SkipLast(1).ToList.ForEach(Sub(row)
row(2)=23
End Sub)

Hi @Demo_User

Try this:

For Each row As DataRow In Dt.AsEnumerable().Take(Dt.Rows.Count - 1).ToList()
    row(2) = 23
Next

Hope it helps!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.