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

查看:10
本文介绍了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?

推荐答案

Access 曾经有自己不兼容的 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 服务器),它可能只会理解百分号.

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天全站免登陆