快来看看!100分
<%qymc=session("qymc")
sslb=session("sslb")
qyzz=session("qyzz")
flag=""
sql="select * from wsfg_qyzz where "
split_symbol=""
if qymc<>"" then
sql=sql+flag+"qymc='"+qymc+"'"
flag=" and "
condition=condition+split_symbol+"企业名称->"+qymc
split_symbol="、"
end if
if sslb<>"null" then
sql=sql+flag+"sslb='"+sslb+"'"
flag=" and "
condition=condition+split_symbol+"所属类别->"+sslb
split_symbol="、"
end if
if qyzz<>"" then
sql=sql+flag+"qyzz='"+qyzz+"'"
flag=" and "
condition=condition+split_symbol+"企业资质->"+qyzz
split_symbol="、"
end if
set conn=connect()
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3
%>这是三个并列条件的查询,那么再加一个日期查询
日期是通过三个下拉列表框选择的。
那么这个日期查询的代码怎么写呀?
问题点数:100、回复次数:34Top
1 楼bill_hongs(hongs)回复于 2002-01-18 17:28:21 得分 0
convert(char(10),rq,111)=year+"/"+month+"/"+dayTop
2 楼andyting(andyting)回复于 2002-01-18 17:28:33 得分 0
四个条件同时可选也可不选的查询。
问题出在日期查询上面。
大家帮帮我吧!Top
3 楼andyting(andyting)回复于 2002-01-18 17:30:08 得分 0
在我的程序中改谢谢!!Top
4 楼andyting(andyting)回复于 2002-01-18 17:36:45 得分 0
没么没人帮我):Top
5 楼Talon(Talon)回复于 2002-01-18 17:39:56 得分 0
if qyzz<>"" then
sql=sql+flag+"qyzz='"+qyzz+"'"
flag=" and "
condition=condition+split_symbol+"企业资质->"+qyzz
split_symbol="、"
end if
------------------------------插入的代码
'日期列表中没有空白项
theday=request.form("theday")
themonth=request.form("themonth")
theyear=request.form("theyear")
thdate=theyear&"-"&themonth&"-"&theday
sql=sql+flag+"thedate='"&thedate&"'"
--------------------------------
set conn=connect()
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3
试试看呀:)Top
6 楼andyting(andyting)回复于 2002-01-18 17:44:38 得分 0
日期字段只有一个呀?现在有三个下拉列表框year month day
你这样写不对吧?Top
7 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 17:44:51 得分 0
<%qymc=session("qymc")
sslb=session("sslb")
qyzz=session("qyzz")
flag=""
sql="select * from wsfg_qyzz where "
split_symbol=""
if qymc<>"" then
sql=sql+flag+"qymc='"+qymc+"'"
flag=" and "
condition=condition+split_symbol+"企业名称->"+qymc
split_symbol="、"
end if
if sslb<>"null" then
sql=sql+flag+"sslb='"+sslb+"'"
flag=" and "
condition=condition+split_symbol+"所属类别->"+sslb
split_symbol="、"
end if
if qyzz<>"" then
sql=sql+flag+"qyzz='"+qyzz+"'"
flag=" and "
condition=condition+split_symbol+"企业资质->"+qyzz
split_symbol="、"
end if
if sj<>"" then
sql=sql+flag+"sj='"+(sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')+"'"
flag=" and "
condition=condition+split_symbol+"时间->"+sj
split_symbol="、"
end if
set conn=connect()
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3
Top
8 楼andyting(andyting)回复于 2002-01-18 18:02:47 得分 0
里面少了个 )
sql=sql+flag+"sj='"+(sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')+"'"
Top
9 楼andyting(andyting)回复于 2002-01-18 18:07:00 得分 0
里面少了个 )加哪呢?
sql=sql+flag+"sj='"+(sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')+"'"
Top
10 楼andyting(andyting)回复于 2002-01-18 18:28:56 得分 0
???????????/Top
11 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 18:29:57 得分 0
不好意思,应该这样!
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')Top
12 楼andyting(andyting)回复于 2002-01-18 18:44:06 得分 0
出错提示
Microsoft VBScript 编译器错误 错误 '800a0409'
未结束的字符串常量
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')
Top
13 楼andyting(andyting)回复于 2002-01-18 18:49:56 得分 0
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year + "-" + month + "-" + date + " 23:59:59')"
出错提示
Microsoft VBScript 运行时错误 错误 '800a01c2'
错误的参数个数或无效的参数属性值: 'year'
Top
14 楼andyting(andyting)回复于 2002-01-18 18:55:36 得分 0
: beyond_xiruo(希偌)
?????????Top
15 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 19:38:39 得分 0
对了,请把那几个保留字改一下,year,month,date,呵呵!Top
16 楼andyting(andyting)回复于 2002-01-18 20:00:37 得分 0
改成什么呀???Top
17 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 20:08:29 得分 0
比如改成year1,month1,date1Top
18 楼andyting(andyting)回复于 2002-01-18 20:08:31 得分 0
beyond_xiruo(希偌)
回答呀!!!!!!!!!!!!!1Top
19 楼andyting(andyting)回复于 2002-01-18 20:26:41 得分 0
比如改成year1,month1,date1
改后行吗?Top
20 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 20:37:28 得分 0
你试试看
我原来就是用year1的Top
21 楼andyting(andyting)回复于 2002-01-18 20:43:52 得分 0
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year + "-" + month + "-" + date + " 00:00:00') and CONVERT(datetime(8),'" + year1 + "-" + month1 + "-" + date1 + " 23:59:59')"
这样好像还是按日期查不出你选择的日期
Top
22 楼andyting(andyting)回复于 2002-01-18 20:55:22 得分 0
???????????????Top
23 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 21:55:07 得分 0
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year1 + "-" + month1 + "-" + date1 + " 00:00:00') and CONVERT(datetime(8),'" + year1 + "-" + month1 + "-" + date1 + " 23:59:59')"Top
24 楼beyond_xiruo(CorruptionException)回复于 2002-01-18 21:57:06 得分 0
你的si字段应该是datetime类型!Top
25 楼andyting(andyting)回复于 2002-01-19 15:09:58 得分 0
是的。Top
26 楼andyting(andyting)回复于 2002-01-19 15:13:53 得分 0
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year1 + "-" + month1 + "-" + date1 + " 00:00:00') and CONVERT(datetime(8),'" + year1 + "-" + month1 + "-" + date1 + " 23:59:59')"
为什么要写成year1 month1 day1??????Top
27 楼andyting(andyting)回复于 2002-01-19 16:18:21 得分 0
现在唯一的就是年可以查出可是月和日还查不出Top
28 楼beyond_xiruo(CorruptionException)回复于 2002-01-20 19:30:28 得分 0
在日期查询里,“-”符号是不允许的,除非你把字段改为字符型。
因此你输入年的时候没有“-”可以查询得出结果,当你用年-月-日来查的时候就不可以了!
Top
29 楼andyting(andyting)回复于 2002-01-20 19:55:26 得分 0
那怎么改呢Top
30 楼andyting(andyting)回复于 2002-01-20 19:56:20 得分 0
对了我是选择年月日的没有-Top
31 楼andyting(andyting)回复于 2002-01-21 17:21:40 得分 0
??????????????????????/Top
32 楼beyond_xiruo(CorruptionException)回复于 2002-01-21 17:39:01 得分 0
sql=sql+flag+"sj between CONVERT(datetime(8), '" + year1 + "-" + month1 + "-" + date1 + " 00:00:00') and CONVERT(datetime(8),'" + year1 + "-" + month1 + "-" + date1 + " 23:59:59')"
这句不行吗?
不写成year month day是因为他们是保留字!
Top
33 楼lsaturn(土星-站了一晚)回复于 2002-01-21 17:48:46 得分 0
解决没有?
我看糊涂了Top
34 楼VFP(VFP)回复于 2002-02-28 01:37:56 得分 100
dTop




