中国南海人工岛图片:ASP怎么做累加呀

来源:百度文库 编辑:高考问答 时间:2024/05/05 15:52:43
我想做一个ASP的累加,但明明有数据,可返回的结果为什么总是0呀
以下是我写的代码,请各位高手指教
<%
dim yulin3(999)
n=0
i=0
temp=shijian(0)+shijian(1)+shijian(2)+"%"
set table40=server.CreateObject("adodb.connection")
table40.open "dsn=zdz;UID=ybywb;PWD=zyt029;Database=elementinfo;"
set rs40=table40.execute("select * from tabTimeData where ObservTimes like '"&temp&"'and StationNum='57119'")
while (not rs40.eof) and (n<999)
yulin3(i)=rs40("Precipitation")
%>
<%
if yulin3(i)="" or yulin3(i)="N" then
yulin3(i)="0"
else
yulin3(i)=yulin3(i)/10
end if
yulinjiangshui=yulin3(i)+0
rs40.movenext
wend
rs40.close
table40.close
%>
<%
i=i+1
n=n+1
%>
数据库里不仅有数字,还有字符N,所以不能直接加的

rs40.movenext
i=i+1
n=n+1
wend

将: set rs40=table40.execute("select * from tabTimeData where ObservTimes like '"&temp&"'and StationNum='57119'")
改成:

set rs40=table40.execute("select sum(*) from tabTimeData where ObservTimes like '"&temp&"'and StationNum='57119'")

就可以将符合条件的总和

select sum("要求和的字段名") from tabTimeData where ObservTimes like '"&temp&"'and StationNum='57119'"