Hey everybody! I’m having a little trouble here. Basically, I am trying to assign to check if email is already exist or not before copying the datatable. I created 2 Datatable: Result_DT contain null and Master_DT contain the Email. I have this error while I was debug and it says Error: Source contains no datarows.
I write the expression in the Assign Activity - Master_DT.AsEnumerable().Where(Function(row) row(“Email”).ToString=item(“Email”).ToString).CopyToDataTable()
I am trying to cater for exception where there is no record retrieve from the Excel file but to no avail.
@anon12805641, So before assigning Master_DT to Result_DT, add a assign activity with Result_DT = Master_DT.Clone
And your condition should be changed in if conditon, it should be Master_DT.Rows.Count > 0.
Solution from @Palaniyappan: dt.Rows.Count = 0 OR dt.Rows.Count>=1
Then use Clone to get properties of Master_DT (Clone is only a clone no rows will be found when you clone. It only copies the column types and names to the assigned datatable)
I suggest you check what the output of your linq query is. I think you are missing adding rows in your linq query.
You can try to specify how many rows you want to copy to the Result_DT as well. My know how of linq query is rudimentary. I use .Take(numberofRows).CopyToDataTable() usually.
@anon12805641, Can you check the count of Master_DT.AsEnumerable().Where(Function(row) row(“Email”).ToString=item(“Email”).ToString).ToArray.Count > 0 before assigning to Result_DT.
Hello Peter, I have a query on the same topic. There’s a select query being used for my datatable and the error I am getting is that the "datatable has no datarows. "
the query I am using to solve this is::: dt_TransactionHistory.Select("[TransactionDescription]=‘Coverage Change’ OR [TransactionDescription]=‘Terminate Coverage’ ").CopyToDataTable.Rows.Count=0
however this is not able to resolve the issue as I get the same error.
What could be done in this case?
Hi Peter thanks for responding quickly. The mistake that I was doing was that I was including copytodatatable() method at the end. It is redundant while taking count post filteration in case there are no data captured using the query.