I have code like this:
DataRow[] drClaimCPT;
drClaimCPT = dtCpt.Select("CLAIM_NUMBER == " + claimNo + "");
When I run, I got an error:
Syntax error: Missing operand before '=' operator.
What did I do wrong?
This should work for you if type is integer:
drClaimCPT = dtCpt.Select("CLAIM_NUMBER = " + claimNo + "");
for string:
drClaimCPT = dtCpt.Select("CLAIM_NUMBER = '" + claimNo + "'");
I assume your claimNo
is number
, the right syntax is;
dtCpt.Select("CLAIM_NUMBER = " + claimNo + "");
DataTable.Select
method uses same rules with DataColumn.Expression
property by the way.
If your claimNo
is a string
, you should use single quotes with it.
dtCpt.Select("CLAIM_NUMBER = 'claimNo'");
From documentation;
User-Defined Values
User-defined values may be used within expressions to be compared with column values. String values should be enclosed within single quotation marks
Your actual issue was using double '=' - that is the coding equals - rememebr it is SQL equals - so only it should be "CLAIM_NUMBER = claimNo" , not "CLAIM_NUMBER == claimNo".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With