紧急求救急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急

mengqingwei 2006-10-24 05:24:17
我在使用ASP时,我在使用MQYSQL数据库,想查询前40天记录(select top 40 pic, name,id from yinxiang )请问那么简单的一个语句为什么MYSQL几不支持,还有我的在我的本机SQL SERVER 数据库和ACCESS数据库连OR上都测试过的分页代码,但是上传到服务器上,就不支持!郁闷啊,那位高人如果使用过MYSQL数据库能把分页的代码和查询前N条记录的代码发给,万分感谢,我的邮箱是:wwwmengqingwei@sohu.com,我以前没使用过MYSQL数据库,急急急急急急急急急急急急急急------------
...全文
277 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
李向荣 2006-10-25
  • 打赏
  • 举报
回复
但是,你这种分页方式的效率太低,建议,直接用limit选出所需要的记录。
李向荣 2006-10-25
  • 打赏
  • 举报
回复
</p>
<table cellpadding="3" cellspacing="1" border="1" width="88%" class="tableBorder" align=center>
<%'开始分页
Const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
set rs=conn.execute("select count(*) from guanlijilu")
totalPut=rs.recordcount
rs.open "select * from guanlijilu",conn,1,1

if err.number<>0 then
response.write "数据库中无数据"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 您还没有添加新闻!</p>"
else


if currentpage<1 then
currentpage=1
end if

if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if

if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"userlook.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"userlook.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"userlook.asp"
end if
end if
end if

sub showContent
dim i
i=0

%>
<tr>
<td class="forumRowHighlight">
<div align="center"> 管理员ID</div></td>
<td class="forumRowHighlight">
<div align="center">管理时间</div></td>
<td class="forumRowHighlight">
<div align="center">进入时间</div></td>
<td class="forumRowHighlight">
<div align="center">退出时间</div></td>
</tr>
<%do while not rs.eof%>
<tr>
<td class="forumRowHighlight"><div align="center">
<% =rs("name") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("shijian") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("intime") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("outtime") %>
</div></td>
</tr>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</table>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If

Response.Write "<form method=Post action='userlook.asp'>"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href='userlook.asp'?page=1 class='contents'>首页</a> "
Response.Write "<a href='userlook.asp'?page="¤tPage-1&" class='contents'>上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href='userlook.asp'?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href='userlook.asp'?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"条新闻 "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' class='button' value='GO' name='cndok'></form>"
End Function
%>
<br/>
mengqingwei 2006-10-25
  • 打赏
  • 举报
回复
出错信息是没有,显示可以显示,但只显示第一页,下一页不能显示,并且总的记录书显示的是-1,上面的高手说的对,MQSQL不支持RS.RECORDCOUNT,郁闷哦,你们以前遇到这样的情况吗?
jolinkyo 2006-10-25
  • 打赏
  • 举报
回复
说的话不清不楚的,对得起我们的国学吗
银狐被占用 2006-10-25
  • 打赏
  • 举报
回复
翻页可以借签一下我写的。
银狐被占用 2006-10-25
  • 打赏
  • 举报
回复
http://blog.csdn.net/baby97/archive/2006/06/07/777629.aspx

MYSQL不支持TOP函数,用limit
sy_binbin 2006-10-25
  • 打赏
  • 举报
回复
好象MYSQL不支持rs.recordcount,所以查到的应该是-1吧
zhanghongwen 2006-10-25
  • 打赏
  • 举报
回复
没用过MYSQL,UP
李向荣 2006-10-25
  • 打赏
  • 举报
回复
有什么出错信息吗,是什么现象?代码看不出什么问题。
mengqingwei 2006-10-24
  • 打赏
  • 举报
回复
谢谢上面的高手,再请问你一下,为什么说在其他数据库里支持的分页但在MYSQL 里就不支持了?你看我的代码:
</p>
<table cellpadding="3" cellspacing="1" border="1" width="88%" class="tableBorder" align=center>
<%'开始分页
Const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from guanlijilu",conn,1,1

if err.number<>0 then
response.write "数据库中无数据"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 您还没有添加新闻!</p>"
else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if

if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"userlook.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"userlook.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"userlook.asp"
end if
end if
end if

sub showContent
dim i
i=0

%>
<tr>
<td class="forumRowHighlight">
<div align="center"> 管理员ID</div></td>
<td class="forumRowHighlight">
<div align="center">管理时间</div></td>
<td class="forumRowHighlight">
<div align="center">进入时间</div></td>
<td class="forumRowHighlight">
<div align="center">退出时间</div></td>
</tr>
<%do while not rs.eof%>
<tr>
<td class="forumRowHighlight"><div align="center">
<% =rs("name") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("shijian") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("intime") %>
</div></td>
<td class="forumRowHighlight">
<div align="center">
<% =rs("outtime") %>
</div></td>
</tr>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</table>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If

Response.Write "<form method=Post action='userlook.asp'>"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href='userlook.asp'?page=1 class='contents'>首页</a> "
Response.Write "<a href='userlook.asp'?page="¤tPage-1&" class='contents'>上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href='userlook.asp'?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href='userlook.asp'?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"条新闻 "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' class='button' value='GO' name='cndok'></form>"
End Function
%>
<br>
李向荣 2006-10-24
  • 打赏
  • 举报
回复
select pic, name,id from yinxiang limit 0,40
李向荣 2006-10-24
  • 打赏
  • 举报
回复
MYSQL 更简单,可以使用limit,到百度里搜一下。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧