SQL的Between...And...使用问题!

poctopus 2004-04-01 05:43:58
在select语句中between #月/日/年# and #月/日/年# 就通过RS(0)显示数据。
但是使用“between sdata and edata ”Sdata、Edata已经定义,这些数据就是不能显示!!


<%
syear=request("s-year")
smonth=request("s-month")
sdate=request("s-date")
eyear=request("e-year")
emonth=request("e-month")
edate=request("e-date")

sdata="#"&smonth&"/"&sdate&"/"&syear&"#"
edata="#"&emonth&"/"&edate&"/"&eyear&"#"

dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("/database/cc.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr

rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between sdata and edata")

%>




<%=rs(0)%>、<%=rs(1)%>、<%=rs(2)%>、<%=rs(3)%>、<%=rs(4)%>、<%=rs(5)%>
...全文
51 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
vvfish119 2004-04-01
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between #"&sdata&"# and #"&edata&"#")
回复
银狐被占用 2004-04-01
错了。
应该是:
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between '"&sdata&"' and '"&edata&"'")
回复
银狐被占用 2004-04-01
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between sdata and edata")

换成:

rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between "&sdata&" and "&edata)
回复
xieyj 2004-04-01
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between sdata and edata")
改成:
sql server 数据库:

rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between '"&sdata&"' and '"&edata&"'")

access 数据库:
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between #"&sdata&"# and #"&edata&"#")
回复
loveweb 2004-04-01
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between sdata and edata")
+++++++++
try
rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between '"&sdata&"' and '"&edata&"'")
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告