很明显没有把SQL的合成查询连接过去,改变的方法是把s_sql这个变量设置成session变量,这样就可以跨页面传递了。
s_sql="select * from kaoqin" & s_sql
session("s_sql")=s_sql
rst.open session("s_sql"),cnn,1,1
这样测试一下
谢谢你,我照你的方法做了,但又有新的问题出来啦
错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/attend/findattendinfo.asp, 第 125 行
<html>
<head>
<title>考勤数据</title>
</head>
<script language="vbscript" >
sub b_find1_onclick
window.navigate "findattendinfo.asp"
end sub
</script>
<body>
<div align="center">
<% if session("s_username")<> "" then %>
<caption><b>考勤数据</b></caption>
<form name="f_find" method="post" action="findattendinfo.asp">
<table bgcolor="#cceeff">
<tr>
<td align="right">员工姓名:</td>
<td><input type="text" name="t_name" size="10"> </td>
<td>员工号:</td>
<td><input type="text" name="t_oved" size="10"></td>
<td>至</td>
<td><input type="text" name="t_oved1" size="10"></td>
<td><input type="submit" name="b_find" value="查询" style="{width: 80px}"></td></tr>
<tr>
<td>刷卡类型:</td>
<td><select size="1" name="s_attend" style="{width: 80px}">
<option value=""></option>
<option value="上班">上班</option>
<option value="下班">下班</option>
<option value="上午下班">上午下班</option>
<option value="下午上班">下午上班</option>
</select> </td>
<td>刷卡日期:</td>
<td><input type="text" name="t_date" size="10"></td>
<td>至</td>
<td><input type="text" name="t_date1" size="10"></td>
<td colspan="2" align="center"><input type="reset" value="全部重写">
</tr>
</table>
</form>
<%
dim cnn,rst,s_sql,currentpage,rowcount,i,s_sql1
dim s_name,s_oved,s_oved1,s_attend1,s_date,s_date1
dim s_ovedno
s_name=request("t_name")
s_oved=request("t_oved")
s_oved1=request("t_oved1")
s_attend1=request("s_attend")
s_date=request("t_date")
s_date1=request("t_date1")
currentpage=request.querystring("currentpage")
if currentpage="" then
currentpage=1
end if
set cnn=server.createobject("adodb.connection")
set rst=server.createobject("adodb.recordset")
cnn.connectionstring="driver={sql server};server=xiaozhen;uid=sa;pwd=sa;database=findsystem"
cnn.open
if s_name="" then
else
if s_sql="" then
s_sql=" where 姓名 like '%" & s_name & "%'"
else
s_sql=s_sql & " or 姓名 like '%" & s_name & "%'"
end if
end if
if s_attend1="" then
else
if s_sql="" then
s_sql=" where 刷卡类型 ='" & s_attend1 & "'"
else
s_sql=s_sql & " or 刷卡类型 ='" & s_attend1 & "'"
end if
end if
if s_oved="" and s_oved1="" then
else
if s_sql="" then
s_sql=" where 员工号 >='" & s_oved & "' and 员工号<='" & s_oved1 & "'"
else
s_sql=s_sql & " or 员工号 >='" & s_oved & "' and 员工号<='" & s_oved1 & "'"
end if
end if
if s_date="" and s_date1="" then
else
if s_sql="" then
s_sql=" where 刷卡日期 >='" & s_date & "' and 刷卡日期 <='" & s_date1 & "'"
else
s_sql=s_sql & " or 刷卡日期 >='" & s_date & "' and 刷卡日期 <='" & s_date1 & "'"
end if
end if
rst.cursortype=adopenstatic
rst.pagesize=10
s_sql1="select * from kaoqin" & s_sql
rst.open s_sql1,cnn,1,1
response.write s_sql1
if rst.eof then
else
rst.absolutepage=cint(currentpage)
l_rowcount=0
%>
<table align="center" border="1">
<tr bgcolor="#99ccff">
<td align="center">员工号</td>
<td align="center">姓名</td>
<td align="center">卡号</td>
<td align="center">刷卡类型</td>
<td align="center">刷卡日期</td>
<td align="center">刷卡时间</td>
</tr>
<%
while not rst.eof and l_rowcount < rst.pagesize
%>
<tr>
<% for l_i=0 to rst.fields.count - 1 %>
<% if l_i=0 then %>
<td nowrap ><a href="<% =url %>/attend/ovedinfo1.asp?ovedno=<% = rst(l_i) %>"><% =rst(l_i) %></a></td>
<% else %>
<td nowrap align="center" width="90"><% = rst(l_i) %></td>
<% end if %>
<% next %>
</tr>
<%
l_rowcount=l_rowcount + 1
rst.movenext
wend
end if
%>
</table>
<h5><p>共<% =rst.pagecount %>页 当前页:<% =currentpage %>/<% =rst.pagecount %>
<%
if currentpage > 1 then
Response.Write "<A href = findattendinfo.asp?currentpage="&(currentpage - 1)&"&t_name="&s_name&"&t_oved="&s_oved&"&t_oved1="&s_oved1&"&t_attend="&s_attend&"&t_date="&s_date&"&t_date1="&s_date1&">[上一页]</a>"
end if
%>
<%
if not rst.eof then
Response.Write "<A href = findattendinfo.asp?currentpage="&(currentpage - 1)&"&t_name="&s_name&"&t_oved="&s_oved&"&t_oved1="&s_oved1&"&t_attend="&s_attend&"&t_date="&s_date&"&t_date1="&s_date1&">[下一页]</a>"
end if
%>
<a href="<% =url %>/login/host.asp">返回</a>
</p>
</h5>
<%
else
response.redirect "/default.asp" %>
<% end if %>
</div>
</body>
</html>