Syntax error: Missing operand before '=' operator

I have a code like this:

DataRow[] drClaimCPT;
drClaimCPT = dtCpt.Select("CLAIM_NUMBER == " + claimNo + "");

When I started, I received an error message:

Syntax error: Missing operand before '=' operator.

What did I do wrong?

+4
source share
3 answers

This will work for you if the type is integer:

drClaimCPT = dtCpt.Select("CLAIM_NUMBER = " + claimNo + "");

for string:

drClaimCPT = dtCpt.Select("CLAIM_NUMBER = '" + claimNo + "'");
+10
source

I assume your claimNo- number, the correct syntax is:

dtCpt.Select("CLAIM_NUMBER = " + claimNo + "");

DataTable.SelectThe method uses the same rules with the DataColumn.Expressionproperty by the way.

If yours claimNois string, you should use single quotes with it.

dtCpt.Select("CLAIM_NUMBER = 'claimNo'");

From the documentation;

Custom values

.

+1

Your actual problem was to use double '=' - this is the encoding equivalent - rememebr is SQL, so it should be "CLAIM_NUMBER = ClaimNo" and not "CLAIM_NUMBER = = requireNo".

+1
source

Source: https://habr.com/ru/post/1526701/


All Articles