Assign: Syntax error: Missing operand after 's' operator

I’ve been running this process for weeks unattended no issues. All of a sudden today i get an error saying “Assign: Syntax error: Missing operand after ‘s’ operator.”.

This is the assign that gets the error. I tried deleting the assign and retyping everything (suggestion i saw on another post) but that didn’t fix the error.

image

HI @atarantino

Checkout this Expression

dtDefendants.AsEnumerable().Where(Function(d) d("Defendant").ToString.Equals(CurrentRow("Defendants").ToString)).CopyToDataTable

Regards
Sudharsan

that won’t work.

image

Try this:

dtDefendants.Select(“Defendant = '” + CurrentRow(“Defendants”).ToString() + “'”)

try this @atarantino

dtDefendants.AsEnumerable().Where(Function(d) d("Defendant").ToString.Equals(CurrentRow("Defendants").ToString)).ToArray().CopyToDataTable

Can you try this @atarantino

dtDefendants.Select("[Defendant ]='"+CurrentRow["Defendants"].Tostring+"'")

Regards
Sudharsan

still same error.

Doesn’t work.

Doesn’t work. I get the same error.

Hi,

I guess this error is caused by single quote in CurrentRow(“Defendant”) such as “One’s”.
For now, can you try the following expression?

dtDefendants.Select("Defendant = '"+CurrentRow("Defendant").ToString.Replace("'","''")+"'")

Regards,

You have a value in CurrentRow(“Defendants”) that has an apostrophe in it. Looks like probably 's in one of the values.

What is the variable datatype of DefendantRecord? @atarantino
image

I solved it. My data had a ’ in it so i did a .replace(“'”, “”) and it works.

You won’t get the error now, but your Select won’t work.

Say the value is “Arnold’s” inside dtDefendants. Now your select is “Defendant = ‘Arnolds’” which won’t match.

The correct way to solve it is to escape the single quote by replacing it with two single quotes.

can you please help me with the code?

this is what i have after my change

dtDefendants.Select(“Defendant = '”+CurrentRow(“Defendants”).ToString.Replace(“'”,“”)+“'”)

Just put two single quotes in your replace statement in the second parameter.

dtDefendants.Select(“Defendant = ‘”+CurrentRow(“Defendants”).ToString.Replace(“’”,“‘’”)+“'”)

It’s hard to see, but the second parameter in the .Replace(,) is now a double quote then two single quotes then a double quote.

What this does is escape the single quote so the Select knows to treat it as part of the value, not part of the syntax.

Note that you can’t copy/paste from here into Studio. The quotes won’t be correct.

1 Like

No worries - i put it in notepad and was able to see it better. I really appreciate the help.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.