Invalid SQL query in property "wherecondition".

Novice User asked on June 24, 2020 22:06

I am using custom macro in where condition in repeater with custom query web part like this

(ClassName = '') and {%GetSomething())%}

Getsomething() macro is creating another half of the SQL query which brings a string like this

(Subject = 'Math' or Subject = 'Science')

When I run this query in SQL it works fine but on page it gives me

Invalid SQL query in property "wherecondition".

What I am missing ?

Correct Answer

Brenden Kehren answered on June 24, 2020 22:19

This syntax is incorrect:

(ClassName = '') and {%GetSomething())%}

You have an extra closing ) you need to remove before the closing macro.

Secondly, you may have to suffix your clause with a macro parameter:

(ClassName = '') and {%GetSomething()|(handlesqlinjection)false%}

because it may automatically try to SQL escape the value you're adding.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.