Reputation: 5162
I am getting a syntax error " Missing operand after 'Price' operator" with the following code, which should be right but obviously isn't. Any thoughts on where the error is?
table.Columns.Add("ADR Price", GetType(Double))
table.Columns.Add("ORD Price", GetType(Double))
table.Columns.Add("Currency Price", GetType(Double))
Dim cDiff As DataColumn = New DataColumn
With cDiff
.DataType = System.Type.GetType("System.Double")
.ColumnName = "Difference"
.Expression = "ADR Price - (ORD Price * Currency Price)"
End With
table.Columns.Add(cDiff)
Upvotes: 1
Views: 1152
Reputation: 460058
I'm fairly sure that the exception is caused by your whitespaces in the column-names.
You should wrap the names in brackets or remove the spaces:
.Expression = "[ADR Price] - ([ORD Price] * [Currency Price])"
But then the next will probably walk into this trap. So in my opinion removing would be better:
.Expression = "ADR_Price - (ORD_Price * Currency_Price)"
Upvotes: 1
Reputation: 3751
This error comes because of an apostrophe in the value ( ' ). Check if the price value is containing any apostrophe, if its containing any, just double it.
See this link: http://aspnetresources.com/blog/apostrophe_in_rowfilter
Upvotes: 0