DataTable Select with both Variables and Contstants




I am trying to use a Select in my DataTable.
It originally worked with two constants

SchedDT.Select("[Job Level] = ‘11’ AND [Work Location] = ‘London’")

I now need to amend the select to use variables.

After scanning the forum I found the syntax to use variables

but I am struggling to work out the syntax for

  1. one variable and one constant
  2. two variables

My current attempt is at

SchedDT.Select( “[Job Level] = '”+convert.ToString(intLevel)+"’" )

This works fine:grinning:

However when I try to add in the constant it errorrs:frowning_face:

SchedDT.Select( “[Job Level] = '”+convert.ToString(intLevel)+"’ " AND [Work Location] = ‘London’)

Any ideas on the correct syntax to use for variable+contstant and variable+variable for these Selects?

thanks in advance


Hi @ToonRobots,

Try this one
SchedDT=SchedDT.Select("[Job Level] = '"+intLevel.ToString()+"' AND [Work Location] ='London'").CopyToDataTable()



Hi Arivu,

That does cure my syntax issue, but causes another problem.

In my original workflow, the results of the select were passed to a DataRow[] variable, which I checked for rows, before continuing with the logic and assigning them into another DT.

Now I am getting Assign : The source contains no DataRows., as with the current selectors there is no data. How would I check before making the Select?



Hi @ToonRobots,

i hope in that DataTable no record matched as per your condition
So use if condition before assigning
SchedDT.Select("[Job Level] = '"+intLevel.ToString()+"' AND [Work Location] ='London'").length>0

True ->Assign the value



Spot on

Many thanks



4 posts were split to a new topic: What UiPath course i should take?