I am trying to perform string operations on a rowitem selected using Foreach loop for Datatable. But it throws exception saying generic .Net error message “Object Reference Not set to an instance of object”.\
** I am doing MS Excel file reading operations **
I have already tried changing object type/variable type, but its a waste.
Thanks in advance!
Can you post the command that you’re trying to do and It’s getting the error?
I have created an example that do some operations with String and Int variable types and use the For each row activity to iterate between the rows from a specific data table.
Main.xaml (10.2 KB)
Kindly check and tell us if it’s what you were expecting.
Did you check if the DataTable has rows?
When there aren’t rows in the data table, the operations inside the For each row activity don’t execute, then it wouldn’t be a problem because it only enters into this activity when there are rows in the data table.
You are right…inside the foreach most commonly you will see Index out of range exception.
I am doing MS excel file related activity… which is doing simple read the xl → save it in a Datatable → Iterate through all rows and → write the rowitem.
This While iterating rowitem using get row item activity, it is throwing exception of Null reference… Hence I can not perform any operation eg. convert to string, convert to int, split, substrings etc
Try to do it like this:
Once inside the For Each you can take the data without using ‘Get Row Item’ activity. Make sure that the row has values or will throw a exception.
You may also try the following:
Main.xaml (9.1 KB)
Thank You Lucas… for this solution.
I have solved the problem by using this as well : row(0).ToString
I have a data table in the browser and I want to loop thorugh it to search for a specific value in every row.
Unfortunately I have now download option for the table.
Is there any option to use the for each activity to loop thorugh the list and/or to store the whole list as a datatable variable?