I have this line of code in c# I keep getting this error=> Syntax error: Missing operand before '&' operator.
Find below is my code
ds.Tables[0].Columns.Add("RESULTS").Expression = "Iif(((ActualWeight >= (.96 * TargetWeight)) && (ActualWeight <= (1.04 * TargetWeight))),[GOOD] )";
You are missing the false
part of the expression as well as Iif
is not syntactically correct. so try something like this
ds.Tables[0].Columns.Add("RESULTS").Expression = "IIF(((ActualWeight >= (.96 * TargetWeight)) And (ActualWeight <= (1.04 * TargetWeight))),[GOOD], [BAD])"
DataTable Expressions are more like VB than C#. The && is not supported by And
is:
ds.Tables[0]
.Columns
.Add("RESULTS")
.Expression = "Iif(((ActualWeight >= (.96 * TargetWeight)) And (ActualWeight <= (1.04 * TargetWeight))),[GOOD],null)";
Note that I also added a false
condition to complete the expression.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.