Unable to Get data row value from collection of object

datatable
powershell
activities

#1

Execute the power-shell script and got the output as collection of Object.While looping that object got the multiple data row, but unable to extract the value from that data rows.

Thanks,
Tharma.K.S.


#2

@TharmaKS Change TypeArgument from object to DataRow and check


#3

If I change the the TypeArgument as DataRow the below exception will occur,

Throw : Unable to cast object of type ‘System.String’ to type 'System.Data.DataRow

Thanks,
Tharma.K.S.


#4

@TharmaKS change it to System.Data.DataRow


#5

Yes, I gave System.Data.DataRow as type argument and checked the above exception only occurred.


#6

@TharmaKS Ur printing datarow directly which is not possible print values column by column in that row.

displaying 1st column in that row 2nd column value
item(0).ToString item(1).ToString
or or

item(0)(0).ToString item(0)(1).ToString

let me know if it works or not.


#7

I have tried the Validation error occurs,

image


#8

@TharmaKS post what error validation ur getting. What is the datatype of variable tt is?


#9

Variable: tt, Data type :collection of Object
Please refer the below image,


#10

@TharmaKS try something like below.


#11

Tried but same error.


#12

@TharmaKS Give type arguement as System.Data.datarow and in writeline item(0).ToString, If ur getting tt as array datarow it will work. Other wise there will be problem in tt variable value.