i need to remove the data row by some condition matched.so i am using IF condition and all fine . Remove data row is throwing an error like collection was modified. so i need to use
Datatable.remove.rows(row) passing row as for each item.
But problem is how can i add this Datatable.remove.rows(row) method into my code like i cannot assign to anything, i am just tried to use in writeline but as expected it thrown error like this expression cannot give any value.
Please advise on above how can i use code Datatable.remove.rows(row).
WriteLine is not for coding , it is for printing any log/line in execution log window
in your case you should pass the same row to remove it using “Remove data row” activity or you can use row index as well
for using "Datatable.remove.rows you can write the code in invoke code activity. or just assign back to same data table like dt= dt.Rows.Remove(row)(which is not a good practice)
@Sriram07 are you by chance doing this in a for each loop? The issue is not with the remove datarow activity, you are getting that error because you are trying to delete rows while iterating through your datatable. You can’t modify a datatable while iterating through it
A better approach is to filter your datatatable using a .Where() or .Select() statement, then use the .CopyToDataTable() if using the .Where() method, or to use the delete row activity if using the .Select() method.
A quick search here should show plenty of ideas on how to perform either of these activities. Let me know if you get stuck and I would be happy to help
@Sriram07 Invoke code just runs vb.net code that you write yourself. I would not recommend using that unless you and everyone else on the development team understands vb.net code and knows how to modify and maintain it. Almost everything can be done using the built-in activities instead.