Home  >  Article  >  Database  >  c#程序中使用"like“查询access数据库查询为空的问题

c#程序中使用"like“查询access数据库查询为空的问题

WBOY
WBOYOriginal
2016-06-07 15:58:451202browse

今天,在开发的过程中发现了一个特别奇怪的问题:access中like查询时候,在Access数据库中执行,发现可以查询出结果,这是在数据库上执行,select * from KPProj where KpName like '*测试*',但是同样的语句在c#程序中却查询为空,这是什么情况呢? 这个问

今天,在开发的过程中发现了一个特别奇怪的问题:access中like查询时候,在Access数据库中执行,发现可以查询出结果,这是在数据库上执行,select * from KPProj where KpName like '*测试*',但是同样的语句在c#程序中却查询为空,这是什么情况呢?

这个问题真让人纠结,通过以前的开发经验,access中like需要用*号,但是sqlserver oracle数据库中要用标准的%,为什么此时就不行呢?经过搜索资料,最后发现是连接access驱动程序的问题,以前用的都是mdb,数据库是accdb,然后使win7 64位开发系统,由于我的程序中连Access用的是oledb驱动程序,所以在这里 不能用“*”,必须用“%”。如果用的是DAO访问Access数据库,则必须用“*”。

发现并不是遇到access就用*,所以要根据实际的驱动来确定;
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn