asp读取access分页
<!--#includefile="CONN.asp"--><p><inputtype="button"name="Submit"value="按ID排序"onclick...
<!-- #include file="CONN.asp" -->
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?
action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?
action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
act=request("action")
set rs=server.createobject("adodb.recordset")
sql="select * from SkyShield order by '"&act&"'"
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
do while not rs.eof and not rs.bof
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing
end if
%>
</table>
帮我看一下,这个为什么不管怎么他都按MAC排序。按ID不起作用。是为什么?
另外。我想在每300条分页。该怎么写呢?我要完整的能直接用的代码。
2楼的答案
ADODB.Recordset 错误 '800a0bb9'
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/regsoft/FolderGuarder/list.asp,行 40 展开
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?
action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?
action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
act=request("action")
set rs=server.createobject("adodb.recordset")
sql="select * from SkyShield order by '"&act&"'"
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
do while not rs.eof and not rs.bof
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing
end if
%>
</table>
帮我看一下,这个为什么不管怎么他都按MAC排序。按ID不起作用。是为什么?
另外。我想在每300条分页。该怎么写呢?我要完整的能直接用的代码。
2楼的答案
ADODB.Recordset 错误 '800a0bb9'
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/regsoft/FolderGuarder/list.asp,行 40 展开
4个回答
展开全部
<!-- #include file="CONN.asp" -->
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
Page_Size=300
act=request("action")
page = CLng(request("page"))
set rs=server.createobject("adodb.recordset")
sql="select * from SkyShield order by "&act
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
pc=rs.PageCount
rc=rs.recordCount
rs.PageSize = Page_Size
rs.MoveFirst
If page < 1 Then page = 1
If page > rs.PageCount Then page = rs.PageCount
rs.AbsolutePage = page
For ipage = 1 To rs.PageSize
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
If rs.EOF Then Exit For
Next
set rs=nothing
conn.close
set conn=nothing
end if
%>
</table>
<table width="100%" border="1">
<tr>
<td align="center">
<%
tpage="?"
if pc>1 then
response.write"页次 "&page&"/"&pc&" 每页 "&Page_Size&" 总数 "&rc&" "
if request("page")<>"" then page = CLng(request("page")) else page =1
If page < 1 Then page = 1
If page = 1 Then
Response.Write ">>首页 >>上一页"
End If
If page <> 1 Then
Response.Write "<a href="&tpage&"page=1>>>首页</a>"
Response.Write " <a href="&tpage&"page=" & (page - 1) & " >>>上一页</a>"
End If
If page <> pc Then
Response.Write " <a href="&tpage&"page=" & (page + 1) & " class='yellow'>>>下一页</a>"
Response.Write " <a href="&tpage&"page=" & pc & " class='yellow'>>>尾页</a>"
End If
If page = pc Then
Response.Write " <font class='white'>>>下一页 >>尾页</font>"
End If
response.write " 跳转到 "& VbCRlf
response.write "<select name=""menu1"" onChange=""window.location.href =this.value"">"& VbCRlf
for fyi=1 to pc
response.write "<option value='"&tpage&"page="&fyi&"'"
if page=fyi then response.write " selected"
response.write ">"&fyi&"</option>"& VbCRlf
next
response.write "</select>页"
end if
%></td>
</tr>
</table>
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
Page_Size=300
act=request("action")
page = CLng(request("page"))
set rs=server.createobject("adodb.recordset")
sql="select * from SkyShield order by "&act
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
pc=rs.PageCount
rc=rs.recordCount
rs.PageSize = Page_Size
rs.MoveFirst
If page < 1 Then page = 1
If page > rs.PageCount Then page = rs.PageCount
rs.AbsolutePage = page
For ipage = 1 To rs.PageSize
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
If rs.EOF Then Exit For
Next
set rs=nothing
conn.close
set conn=nothing
end if
%>
</table>
<table width="100%" border="1">
<tr>
<td align="center">
<%
tpage="?"
if pc>1 then
response.write"页次 "&page&"/"&pc&" 每页 "&Page_Size&" 总数 "&rc&" "
if request("page")<>"" then page = CLng(request("page")) else page =1
If page < 1 Then page = 1
If page = 1 Then
Response.Write ">>首页 >>上一页"
End If
If page <> 1 Then
Response.Write "<a href="&tpage&"page=1>>>首页</a>"
Response.Write " <a href="&tpage&"page=" & (page - 1) & " >>>上一页</a>"
End If
If page <> pc Then
Response.Write " <a href="&tpage&"page=" & (page + 1) & " class='yellow'>>>下一页</a>"
Response.Write " <a href="&tpage&"page=" & pc & " class='yellow'>>>尾页</a>"
End If
If page = pc Then
Response.Write " <font class='white'>>>下一页 >>尾页</font>"
End If
response.write " 跳转到 "& VbCRlf
response.write "<select name=""menu1"" onChange=""window.location.href =this.value"">"& VbCRlf
for fyi=1 to pc
response.write "<option value='"&tpage&"page="&fyi&"'"
if page=fyi then response.write " selected"
response.write ">"&fyi&"</option>"& VbCRlf
next
response.write "</select>页"
end if
%></td>
</tr>
</table>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!-- #include file="CONN.asp" -->
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?
action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?
action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
act=request("action")
set rs=server.createobject("adodb.recordset")
If act="act" then
sql="select * from SkyShield order by mac"
Else
sql="select * from SkyShield order by id"
End If
page=request.queryString("page")
If page="" Then
page=1
End If
rs.open sql,conn,1,1
rs.pagesize=300
If page>rs.pageCount Then
page=rs.pageCount
End if
rs.absolutePage=(page-1)*rs.pagesize
if not(rs.bof and rs.eof) then
For i=1 To rs.pagesize
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
If rs.eof Then Exit for
next
set rs=nothing
conn.close
set conn=nothing
end if
%>
<!--分页的page传值自己写-->
</table>
<p> <input type="button" name="Submit" value="按ID排序" onclick="location.href='list.asp?
action=id'" />
<input type="button" name="Submit2" value="按MAC排序" onclick="location.href='list.asp?
action=mac'" />
</p>
<table border="1" width="100%" id="table1">
<tr>
<td width="20"><b>id</b></td>
<td width="152"><b>mac</b></td>
<td width="165"><b>ip</b></td>
<td width="302"><b>date</b></td>
<td width="10"><b>reg</b></td>
<td width="70"><b>regmd5</b></td>
</tr>
<%
dim act
act=request("action")
set rs=server.createobject("adodb.recordset")
If act="act" then
sql="select * from SkyShield order by mac"
Else
sql="select * from SkyShield order by id"
End If
page=request.queryString("page")
If page="" Then
page=1
End If
rs.open sql,conn,1,1
rs.pagesize=300
If page>rs.pageCount Then
page=rs.pageCount
End if
rs.absolutePage=(page-1)*rs.pagesize
if not(rs.bof and rs.eof) then
For i=1 To rs.pagesize
%>
<tr>
<td width="20"><%= rs("id")%></td>
<td width="152"><%= rs("mac")%></td>
<td width="165"><%= rs("ip")%></td>
<td width="302"><%= rs("date")%></td>
<td width="10"><%= rs("reg")%></td>
<td width="70"><%= rs("regmd5")%></td>
</tr>
<%
rs.movenext
If rs.eof Then Exit for
next
set rs=nothing
conn.close
set conn=nothing
end if
%>
<!--分页的page传值自己写-->
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql="select * from SkyShield order by '"&act&"'"
改成
sql="select * from SkyShield order by " & act
-------------
分页
rs.open sql,conn,1,3 下面加
rs.pagesize=300
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<a href="">首页</a>
<a href="xxx.asp?page=<%=epage-1%>">前一页</a>
<a href="xxx.asp?page=<%=epage+1%>">后一页</a>
<a href="xxx.asp?page=<%=rs.pagecount%>">末页</a>
现在是第<%=epage%>页一共有<%=rs.pagecount%>页
<%
改成
sql="select * from SkyShield order by " & act
-------------
分页
rs.open sql,conn,1,3 下面加
rs.pagesize=300
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<a href="">首页</a>
<a href="xxx.asp?page=<%=epage-1%>">前一页</a>
<a href="xxx.asp?page=<%=epage+1%>">后一页</a>
<a href="xxx.asp?page=<%=rs.pagecount%>">末页</a>
现在是第<%=epage%>页一共有<%=rs.pagecount%>页
<%
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql="select * from SkyShield order by '"&act&"'"
改成
sql="select * from SkyShield"
if act<>"" then sql=sql&" order by "&act
第一次打开页面的时候act是空的所以报错
改成
sql="select * from SkyShield"
if act<>"" then sql=sql&" order by "&act
第一次打开页面的时候act是空的所以报错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询