求教 asp时间段查询
<!--#include file="inc/right.asp"-->
<!--#include file="inc/conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=sysConfig%></title>
<link href="images/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td bgcolor="#FFFFFF">
<BR>
<table width="96%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
<tr align="center" bgcolor="#F2FDFF">
<td colspan="5" class="optiontitle">问卷调查统计</td>
</tr>
<%
dim startdate,enddate
startdate = request.form("startdate")
enddate = request.form("enddate")
set rstime = server.CreateObject("adodb.recordset")
sqltime = "select * from Result where datediff('d','" & startdate& "',addtime)>=0 and datediff('d','" &enddate&"',addtime)<=0"
rstime.open sqltime,conn,1,1
%>
<tr align="center" bgcolor="#F2FDFF">
<td colspan="5">
<form id="formtime" name="formtime" method="post" action="ResultTopictime.asp">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="642" height="25" align="right" valign="middle">
起始日期:
<input name="startdate" type="text" id="startdate" size="15" value="2011-12-13"/>
截止日期:
<input name="enddate" type="text" id="enddate" size="15" value="2011-12-14"/></td>
<td width="432" align="left"><input type="submit" name="button" id="button" value="查询" /></td>
</tr>
</table>
</form>
</td>
</tr>
<%
sqlTotal="select count(id) as TotalNum from Result where datediff('d','" & startdate& "',addtime)>=0 and datediff('d','" &enddate&"',addtime)<=0"
set rsTotal=server.createobject("adodb.recordset")
rsTotal.open sqlTotal,conn,1,1
total=rsTotal("TotalNum")
if total=0 then '判断是否有问卷信息
%>
<tr>
<td colspan="5" bgcolor="#ffffff">目前还没有问卷信息提交!</td>
</tr>
<%
else '有问卷统计信息
rsTotal.close
set rsTotal=nothing
%>
<tr>
<td colspan="5" bgcolor="#ffffff" align="right">有效答卷:<%=total%> 份</td>
</tr>
<%
dim sqlInfo,rsInfo
sqlInfo="select * from Info "
Set rsInfo= Server.CreateObject("ADODB.Recordset")
rsInfo.open sqlInfo,conn,1,1
if rsInfo.eof then '判断是否有问卷信息
response.Write("<tr align='center' bgcolor='#ffffff'><td colspan='8'>还没有问卷信息,请先添加问卷信息。</td></tr>")
else '有问卷信息
For i = 1 to rsInfo.recordcount
Cha="topic"&i
%>
<tr bgcolor="#ebf0f7">
<td colspan="5" class="title"><%=i%>、<%=rsInfo("Topic")%></td>
</tr>
<%for n=1 to rsInfo("TCount")%>
<%if rsInfo("Option"&n) <>"" then%>
<tr bgcolor="#ffffff" onmouseover='this.style.background="#F2FDFF"' onmouseout='this.style.background="#FFFFFF"'>
<td width="40%"><%=rsInfo("Option"&n)%></td>
<td>
<%
res="·"&rsInfo("Option"&n)&"√"
sql="select count("&Cha&") as sum from Result where "&Cha&" like '%"&res&"%'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<font color="#ff0000"><%=rs("sum")%></font>票 (<%=FormatPercent(rs("sum")/total)%>)</td>
<td width="45%"><img src="images/vote.jpg" width=<%=rs("sum")%> height=10></td>
</tr>
<%end if%>
<%next%>
<%
rsInfo.movenext
next'逐一查询结束
rsInfo.close
set rsInfo=nothing
rs.close
set rs=nothing
end if
end if
%>
<%
rstime.movenext
rstime.close
set sqltime=nothing
%>
</table>
</td>
</tr>
</table>
<br>
</body>
</html>
这样写对吗?