菜鸟求教,分页出错
<% Dim cn,rs Dim iPage dim lieming lieming=request.form("lieming") Set cn = Server.CreateObject("ADODB.Connection") cn.Open "Driver={SQL Server};Server=zhuoming;Database=ASPTest;" & _ "UID=sa;PWD=19821204" Set rs = Server.CreateObject("ADODB.RecordSet") Set rs.ActiveConnection = Cn rs.PageSize = 2 rs.CursorType = 3 rs.Open "SELECT * FROM information order by "&lieming&" desc " If Len(Request("page")) = 0 Then iPage = 1 Else iPage = Request("page") End If rs.AbsolutePage = iPage %> <p align="center">图书信息第<% =iPage%>页</p> <table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="646" align="center"> <tr> <td width="25%">编号</td> <td width="25%">价格</td> <td width="25%">出版日期</td> <td width="25%">作者</td> </tr> </tr> <% For i =1 To rs.PageSize If Not rs.Eof Then %> <tr> <td width="25%"><%=rs(0)%> </td> <td width="25%"><%=rs(1)%> </td> <td width="25%"><%=rs(2)%> </td> <td width="25%"><%=rs(3)%> </td> </tr> <% End If If Not rs.Eof Then rs.MoveNext Next %> </table> <p align="center"> <% If CInt(iPage) = 1 Then %> 第一页|上一页| <% Else %> <a href="b.asp?page=1">第一页</a>| <a href="b.asp?page=<% = iPage - 1 %>">上一页</a>| <% End If %> <% If CInt(iPage) = CInt(rs.PageCount) Then %> 下一页| 最后一页 <% Else %> <a href="b.asp?page=<% = iPage + 1 %>">下一页</a>| <a href="b.asp?page=<% = rs.PageCount %>">最后一页</a> <% End If %> <% rs.Close Set rs = Nothing cn.Close Set cn = Nothing %> 第一页可以正确显示,可是连接第二页就会出现错误 Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14' [Microsoft][ODBC SQL Server Driver][SQL Server]在关键字 'desc' 附近有语法错误。 如果解决呢? 先多谢了 |