How to iterate datatables from a dataset using foreach?

I’m getting error while assigning the currentitem in Output datatable or WriteRanges.