Error: Source contains no datarows

excel

#1

Hi, I know there are some forums with similar issues. But it still does not solve my issue. I am trying to read range and it shows this error. But when I try the same activity in a different project it works. and my excel file does have datarows and not empty for sure. This error shows before i even filter thus it’s nothing with my schema i suppose. I even tried reinstalling uipath.excel.activities. Do suggest what i can about this error.

CloneMain has thrown an exception

Source: Assign

Message: The source contains no DataRows.

Exception Type: InvalidOperationException

System.InvalidOperationException: The source contains no DataRows.
at System.Data.DataTableExtensions.LoadTableFromEnumerable[T](IEnumerable1 source, DataTable table, Nullable1 options, FillErrorEventHandler errorHandler)
at System.Data.DataTableExtensions.CopyToDataTable[T](IEnumerable1 source) at lambda_method(Closure , ActivityContext ) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity)
at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


Like i said above, i tried looking at the forum. but it doesn’t help me.

Thank You xoxo


#2

Its failing at your assign activity in your For Each Row activity

Do you have a screenshot of that?


#3

Follow below link


#4

@indra it’s not about my schema


#5

Hi,

This error occurs when you are trying to convert an Enumerable(Of Datarow) to a datatable when this one actually contains no row.

You probably are doing something as follow:

dt.Select("[Name]=‘X’").CopyToDataTable but no rows with ‘X are found’, So at the moment you are trying to convert your Enumerable with 0 rows, it fails.

Cheers


#6

@Florent_Salendres Hi yes, im using something like that

cdr.Select(“Client=”+"’"+serverName+"’ ").CopyToDataTable

cdr.Select(“Client =”+"’"+clientName+"’"+" and Agent = ‘Windows File’ and Type = ‘FULL’ and [Type] = 'Weekly '").CopyToDataTable

is the line wrong?


#7

It seems to be syntactically correct, however are you sure that before converting to datatable, the condition you have on your Selects have matching results?

If at one point the do not, it will throw the exception.
One way you can handle it is using

If cdr.Select(“Client=”+"’ “+serverName+” ’ ").Any() Then
cdr.Select(…).CopyToDatatable

Cheers


#8

@Florent_Salendres

Actually there is a star * beside ’ . As to get the next word togather.
Like
cdr.Select(“Client=”+"’"+serverName+"’ ").CopyToDataTable
After I tried one by one, I found out the problem is with the star
I tried using % also cannot. Is any other way around?


#9

[quote=“Florent_Salendres, post:7, topic:60360”]

I have had success using ‘Like’ as the operator instead of ‘=’ when using wildcards.
Possibly:

cdr.Select("[Client] Like ‘"+serverName+"’").CopyToDataTable

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/like-operator


#10