While reading the row value from data table, its showing as null

I have data table(DataTableDt) like this..

FileName FilePath
Main c:\data\main\main.xml
Archive c:\data\archive\archive.xml
Logs c:\data\logs\logs.xml

I tried using the following two expressions to pull the file paths and both of them giving me null. What could be wrong here?
DataTableDt.Rows(1).Item(“FilePath”).ToString
DateTableDt.Rows(1)(“FilePath”).ToString

1 Like

Hi @Krithi1

Are you sure there is data in datatable?

Can you check printing using below:
DataTableDt.Rows.Count

If there is data, then try using below syntax’s

DataTableDt.Rows(1).Item(1).ToString
DataTableDt.Rows(1).Item(“FilePath”).ToString

Alternatively, try reading using below activity:

Hope this helps.

Hi @sonaliaggarwal47

I do have count from the table. but still the expressions are not working

Hi,

Can you check and share content of the datatable from Locals panel using breakpoint in debug run?

If there is expected data, also check if the command works in immediate panel?

Regards,

@Krithi1

One possible reason could be that both columns are consider together as a single column instead of 2..please check the same

Along with row count get the column count as well to know

If column count is 1 then it read as single column..if count is 2 then either header is not taken or it has an extra space or so

Cheers

@Krithi1

Add breakpoint and debug the code to check the content of the Datatable.

You are using the correct expression to access the value.

Hi all,

Its my bad. I was pointing a wrong file. Thank you all.

1 Like