我正在尝试从Access数据库中获取特定记录.
I'm trying to get specific records from an Access database.
该字符串在Access数据库中有效,但在我的VB程序中无效.
The string works in the access database but not in my VB program.
从[Joist Table]中选择[Join Table].*大小与"*#LH *"类似按大小排序,和弦;
SELECT [Joist Table].* FROM [Joist Table] WHERE size Like "*#LH*" ORDER BY size,chord;
如果我使用第一个字符串,则可以使用,但不能使用第二个字符串.我添加了quot变量,以查看使用双引号是否存在问题,但这似乎没有任何影响.我也删除了ORDER BY参数,看是否是问题所在.
If I use the first string, it works, but not the second string. I added the quot variable to see if there were problems using double quotes, but that didn't seem to affect anything. I also removed the ORDER BY parameters too to see if that was the problem.
dsString =选择[Join Table].*从[Joist Table]的WHERE size像" *#LH *";"
dsString = "SELECT [Joist Table].* FROM [Joist Table] WHERE size Like ""*#LH*"";"
也没有运气.
关于如何使LIKE参数起作用的任何想法?
Any idea on how to get the LIKE parameter to work?
推荐答案
Microsoft Access SQL默认情况下使用其他通配符,即星号(*).使用OLEDB时,您应该改用百分号(%).另一种选择是使用未记录的关键字ALIKE代替LIKE(如果您想 在Access中使用百分号). Microsoft Access SQL uses a different wild-card character by default, which is the asterisk (*). When using OLEDB you should use the percent sign (%)instead. The other option is to use the undocumented keyword ALIKE instead of LIKE (if you want to use the percent sign in Access).
更多推荐
SQL字符串不喜欢Like?
发布评论