查错(多条件查询)
我以时间段查询结果,第一名: sql = "select * from AdviceListView where roomcode=2000 and sendopecode>0 and exectime>'" & Trim(DTPicker1.Value) & "' and exectime<'" & Trim(DTPicker2.Value) & "' order by exectime desc"
运行成功。
第二名:sql = "select * from AdviceListView where roomcode=2000 and offcode= " _
+ DataCombo1.BoundText + "and medname like'" & Txtmed.Text & "%" & "'order by intime desc"
运行成功
但将两句加起
sql = "select * from AdviceListView where roomcode=2000 and sendopecode>0 and exectime>'" & Trim(DTPicker1.Value) & "' and exectime<'" & Trim(DTPicker2.Value) & "'and offcode= " _
+ DataCombo1.BoundText + "and medname like'" & Txtmed.Text & "%" & "'order by intime desc"
却不行,请各位帮个忙查一下,在线等
补充一下,我选中时间加科室就运行成功,但单独选中时间就报错:在关键字串and附近有语法错误,这是为什么呢?
[[it] 本帖最后由 jxawgyl 于 2008-6-4 20:04 编辑 [/it]]