I am trying to execute this select statement within my application and encounter the System.Data.EvaluateException "Cannot perform '-' operation on System.String and System.Decimal"
foreach (DataRow dataRow in dt.Rows)
string otherSTR = "some values";
.. stuff happens
double newR = Convert.ToDouble(dataRow["NEW_RATE"]);
dataRow = dataTable.Select("column = '" + otherSTR + "' and (([double_value] - " + newR + ")*-1 < 0.5)
and (([double_value] - " + newR + ")*1 < 0.5)", "Date asc");
... more stuff happens
}
The ["NEW_RATE"] column is stored as a String and the ["double_value"] column is stored as a String. Is there something within the query that I may be overlooking? The row that ["NEW_RATE"] is sourced from is a separate table than the dataTable that the SELECT statement executes in.
The ["NEW_RATE"] column is a "money" type within the database and is received in the form of a String to the application.
When receiving the ["NEW_RATE"] column as a double, I had the newR
assign statement as follows:
double newR = dataRow["NEW_RATE"];
This throws the "Cannot implicitly convert type 'object' to 'double'" error, so I've added the Convert.ToDouble()
method while receiving the ["NEW_RATE"] column as a String, and the "object can not be assigned" error goes away but the "Cannot perform '-' operation" issue still persists.
The response from the SELECT statement should provide the rows within the dataTable which align with the conditional "and" statement, sorted in ascending order of the Date column.