MS Access查询:为什么从VB6应用程序调用LIKE时行为会有所不同? [英] MS Access query: why does LIKE behave differently when being called from VB6 app?

查看:50
本文介绍了MS Access查询:为什么从VB6应用程序调用LIKE时行为会有所不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不使用VB6进行很多编码,但是我现在正在更新现有的应用程序,并且遇到了麻烦.

I don't do a lot of coding with VB6, but I'm updating an existing app now and just encountered a snag.

我发现了问题所在.在VB6中,使用 Like 时,查询必须使用 通配符,但是在MS Access中,您必须使用***** 通配符.

I figured out the problem. In VB6, queries must use the % wild card when using LIKE, but in MS Access, you have to use the ***** wild card.

我正在查询同一个数据库-(在MS Access中).

I'm querying the same database - (it's in MS Access).

在MS Access中进行查询时,以下查询有效:

When querying from within MS Access, the following query works:

SELECT * FROM table WHERE field LIKE '*something*'

当我在VB6中构建该查询时,我必须这样做:

when I build that query in VB6, I have to do this:

SELECT * FROM table WHERE field LIKE '%something%'

发生了什么事?正常吗?

What's happening? Is that normal?

推荐答案

访问曾经具有自己的不兼容SQL版本,因此出于传统原因,我认为它使用*.

Access used to have its own incompatible version of SQL, so I think it uses the * for legacy reasons.

在使用VB6时,通常会使用ODBC和更标准化的SQL,因此会应用更常见的通配符.请记住,VB6不在乎您使用哪个数据库,因此,如果您使用其他内容(例如SQL Server),它可能只会了解百分比符号.

When you use VB6 you usually use ODBC and a more standardized SQL, so the more common wildcards apply. Remember that VB6 doesn't care which DB you use, so if you used something else (e.g., SQL server) it would probably only understand the percentage signs.

我猜想Access-ODBC连接器会为您转换内容.

I am guessing that the Access-ODBC connector converts things for you.

这篇关于MS Access查询:为什么从VB6应用程序调用LIKE时行为会有所不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆