Operator/operand type mismatch

淺唱寂寞╮ 提交于 2021-01-29 09:08:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!