首页 > 解决方案 > ms access - like 关键字在 winform 中不起作用

问题描述

下面是我的查询,如果我删除了类似的条件,它工作正常,甚至等于也工作,但是当我给 Like 时它不起作用。请告诉我我在这里做错了什么

select ID,CustomerName from Master where CustomerName='Something' // This is working or records found

select ID,CustomerName from Master where CustomerName Like '*Something*' // This is not working or no records found

我在 winform 中使用 OleDb

标签: winformsms-access

解决方案


MS Access 使用 Jet-SQL 方言,您的查询将在其中工作,并且当您使用它的提供程序时

select ID,CustomerName from Master where CustomerName Like '*Something*'

您使用 OleDB 提供程序,并且需要在搜索模式中使用其语法、%方法*_方法来查找运算符?LIKE

select ID,CustomerName from Master where CustomerName Like '%Something%'

推荐阅读