How to get the last row from datatable using uipath

How to get the last row from datatable using uipath.

Any suggestions would be helpful.

Thanks,
Nawaz.

drLastVar = dtData.AsEnumerable.Last()
dtData is your datatable
drLastVar is of datatype: DataRow

1 Like

I have checked in message box it is showing System.Data.Datarow

Thanks,
Nawaz.

we would recommend using the debugging panel instead of the message box
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

often a toString will return the datatype when there is not implemented any other toString Representation

Have a look here:
grafik

Type in statements where the yellow mark is and execute it with Enter,Enter

Hello @Mohammed_Nawazuddin
You can use the Find first/Last row activity to achieve this.

Else you can use the below expression: DT is the datatable

DT.Rows.Count.ToString. - for getting the row count
DT.Columns.Count.ToString. – for getting the column count

Thanks so much , I need to extract only one value from the last row as string "T221’. How can I extract it

Thanks,
Nawaz.

Hi @Mohammed_Nawazuddin

Try lastRow = dt.rows.count (if you are added headers than the last row will be count - 1), then activity read cell with properties cell position = String.Format(T{0}, lastRow.ToString) and you should have value of last row.

I am getting the rows count but I am not getting the exact output. Please find the below error screenshot.

1 Like

Hello, @Mohammed_Nawazuddin

Sorry it supposed to be String.Format(“T{0}”, lastRow.ToString)

No it should be alright :). I missed quotation marks before.

Hi @ppr
how do i implement this in UiPath studiox? sorry i am a newbie