vb 操作符丢失 语法错误

来源:百度知道 编辑:UC知道 时间:2024/06/18 06:26:19
我用vb6.0+access进行,现在有个简单的数据库查询问题,提示是上面的题目,现在我把语句写在下面sql = "select * from cfbl where " & x & " "And " & xm & " And " & a4 & " And " & g & " And " & h & " And " & r & ""
If sql = "select * from cfbl where x like '%'and xm like '%'and a4 like '%'and g like '%'and h like '%'and r like '%'" Then
MsgBox "请选择查询条件", , "系统提示"
……
x,xm,a4,g,h,r都是文本型的,不知道为什么总是出这个提示。我做的是个多选查询,这是一小部分代码。谢谢~~

在:
sql = "select * from cfbl where " & x & " "And " & xm & " And " & a4 & " And " & g & " And " & h & " And " & r & ""
中,就不正确的吧?
这里:where " & x & " "And " & xm &
应该是:where " & x & " And " & xm &

sql语句应该没有结束
select * from 表名 where 条件
条件该是像 字段名称=指定字符串 这样的才对。
你这里的条件 仅仅是一个字符串