问题
I'm using the Visual FoxPro OLE DB provider to query a VFP DB and I'm getting:
System.Data.OleDb.OleDbException 'Operator/operand type mismatch`
What could I be doing wrong?
回答1:
In my where
clause I had an int
on one side and a char(15)
on the other side
Table Schema
id int
Query
SELECT *
FROM [some-table]
WHERE id = 'some string'
回答2:
In my case to avoid such kind of inconveniences I do the following I hope it works for you:
var_name = iif(vartype(var_name)=='N',var_name,Val(var_name))
so you avoid two possible errors, if it comes in character with value I convert it into number and if it comes in character without any value it becomes 0.
SELECT *
FROM [some-table]
WHERE id = ?Var_name
来源:https://stackoverflow.com/questions/52809017/operator-operand-type-mismatch