求教!那位能告诉小弟vb中SQL的语法,主要是怎么在select中使用各种类型的变量和怎么在Data.RecordSource 中调用。以及怎么在data.DatabaseName 中引用数据库的相对路径,就是将整个文件夹(程序加数据库)移动后也不影响使用。还有这个vb提示数据类型不匹配
Data3.RecordSource = "select 客房号 from room where 客房类型 like '*" & roomtype & "*'" & "and 客人数<'*" & temp_num & "*'"
我想应该是--&"and 客人数<'*" & temp_num & "*'"--的错误。去掉它就没错了。客人数,temp_num 都是long 客房号,客房类型,roomtype 是string
请高手多多指教。谢谢了
Data3.RecordSource = "select 客房号 from room where 客房类型 like '*" & roomtype & "*'" & "and 客人数<'*" & temp_num & "*'"
我想应该是--&"and 客人数<'*" & temp_num & "*'"--的错误。去掉它就没错了。客人数,temp_num 都是long 客房号,客房类型,roomtype 是string
请高手多多指教。谢谢了
app.path & 路径改正SQL:
星号(*)用百分号(%)代替。
FROM room
WHERE 客房类型 Like '*" & roomtype & "*' And
客人数<" & temp_num & " Or (客人性别 Like '*" & csex & "*'
Or 客人性别 Like '空')SQL这样写是没错的啊,我在机器上也执行了,没有象你说的“参数不足,期待是。”之类提示啊
好象是CAST
改进代码:没有错误提示了。但还有问题Data3.RecordSource = "select 客房号 from room where 客人性别 like '*" & csex & "*' or 客人性别 like '空' and 客人数<" & temp_num & " and 客房类型 like '*" & roomtype & "*'"
现在的问题是总有一个约束条件不执行。 这个不执行的是 客人数< temp_num
Data3.RecordSource="select 客房号 from room where 客人性别 like exist ('*"&csex&"*','空') and
and 客人数<" & temp_num & " and 客房类型 like '*" & roomtype & "*'"