| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 781 人关注过本帖
标题:请各位帮帮忙?
只看楼主 加入收藏
星梦玲
Rank: 1
来 自:汕头
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-5-18
收藏
 问题点数:0 回复次数:5 
请各位帮帮忙?
请各位帮个忙~~我是刚学ASP的,在下面的实现分页的代码中,老出现这个错误:
Microsoft VBScript 运行时错误 '800a000d'
类型不匹配: '[string:ID "
 "]'
\fenye.asp, line 63


原代码是:
<%
   dim Conn, rs
   set conn=server.createobject("ADODB.CONNECTION")  
   conn.open "DBQ="+server.mappath("web.mdb")+";DRIVER=

{Microsoft Access Driver (*.mdb)};"

   Set rs = Server.CreateObject("ADODB.Recordset")
   Key  = Request("Key")
   Sort = Request("Sort")
   Page = Clng(Request("Page"))
   sql = "Select * from xinxi"
   If Key > "" Then sql = sql + " order by " & Key
   If Sort > "" Then sql = sql & " " & Sort
   rs.open sql, conn, 3, 2
   rs.PageSize = 4 '每页显示记录数
   If Page < 1 then Page = 1
   If page > rs.PageCount Then Page = rs.PageCount
   If rs.PageCount > 0 then rs.AbsolutePage = Page
   MySelf = Request.ServerVariables("PATH_INFO")
%>
<html>
<body>
<center>
 <p>
  <font face="Arial" size=5>SQL Server<br>
   Northwind Database MultiPage Control Demo</font>
 </p>
<form action="fenye.asp" method="post">
排序字段:
  <select name="Key">
    <option value="ID" <% If Key="ID" Then Response.Write

"selected" %>>ID</option>
    <option value="userName" <% If Key="userName" Then

Response.Write "selected" %>>userName</option>
  </select>  
输出顺序:
  <select name="Sort">
    <option value="ASC" <% If Sort="ASC" Then Response.Write

"selected" %>>递增</option>
    <option value="DESC" <% If Sort="DESC" Then Response.Write

"selected" %>>递减</option>
  </select>  
  <input type="submit" name="ok" value="确认">
</form>
</center>
  <center>
   <p>
     <font face="Arial" size=5>SQL Server<br>
      Northwind Database MultiPage Control Demo</font>
   </p>
   <table border=0 cellpadding=0 cellspacing=1 width=96%>
<%
   Response.Write("<TR BGCOLOR=#ccccd7>")
   Response.Write("<TD>ID</TD>")
   Response.Write("<TD>username</TD>")
   Response.Write("<TD>title</TD>")
   Response.Write("<TD>text</TD>")
   Response.Write("<TD>createdate</TD>")
   Response.Write("</TR>")
   For i = 1 to rs.PageSize
       If rs.EOF Then Exit For
       If i mod 2=0 Then
          Color = "#ddddd7"
       Else
          Color = "#eeeeef"
       End If
       Response.Write("<TR BGCOLOR=" + Color + ">")
       Response.Write("<TD>"+rs("ID")+"</TD>")
       Response.Write("<TD>"+rs("username")+"</TD>")
       Response.Write("<TD>"+rs("title")+"</TD>")
       Response.Write("<TD>"+rs("text")+"</TD>")
       Response.Write("<TD>"+rs("createdate")+"</TD>")
       Response.Write("</TR>")
       rs.MoveNext   
   Next
%>
   </table>
  </center>
<%
If rs.PageCount > 1 then
%>
   <br>
   <div align="center">
   <a href="<%=MySelf%>?Page=<% =(Page - 1) %>&Sort=<%=Sort%

>&Key=<%=Key%>">上一页</a>??
   <%
   For i = 1 to rs.PageCount
       If i = Page then
          color = "Red"
          response.write " <Font color=" + color + ">" + Cstr(i)

+ "</Font>? "
       Else
          color = "Black"
          response.write " <a href=" + MySelf + "?Page=" + Cstr

((i)) + "&Sort=" + Sort +"&Key="+Key+"><Font color=" + color +

">" + Cstr(i) + "</Font></a>? "
       End If
   Next
   %>??
   <a href="<%=MySelf%>?Page=<%=(Page + 1)%>&Sort=<%=Sort%

>&Key=<%=Key%>">下一页</a>
   </div>
<%
ElseIf rs.PageCount < 1 then
   response.Write "<div align='center'><font color=red>无相关数

据!!...</font></div>"
End If
%>
</body>
</html>

请大家帮个看看是哪里出错~~~我急要用~~~我先谢谢大家~~~~~~~~~

[[it] 本帖最后由 星梦玲 于 2008-5-18 21:12 编辑 [/it]]
搜索更多相关主题的帖子: quot Microsoft web Request Sort 
2008-05-18 20:54
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
Response.Write("<TD>createdate</TD>")

这个是63行,看起来没什么问题。但是我觉得开头这段的几个回车有点问题:
<%
   dim Conn, rs
   set conn=server.createobject("ADODB.CONNECTION")  
   conn.open "DBQ="+server.mappath("web.mdb")+";DRIVER= ----->
{Microsoft Access Driver (*.mdb)};" ---->
把有箭头的两行合并一下试试

<%
   dim Conn, rs
   set conn=server.createobject("ADODB.CONNECTION")  
   conn.open "DBQ="+server.mappath("web.mdb")+";DRIVER={Microsoft Access Driver (*.mdb)};"

   Set rs = Server.CreateObject("ADODB.Recordset")
   Key  = Request("Key")
2008-05-18 20:59
星梦玲
Rank: 1
来 自:汕头
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-5-18
收藏
得分:0 
不可以呀, 还是一样的错误~~
2008-05-18 21:05
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
[bo]以下是引用 [un]星梦玲[/un] 在 2008-5-18 21:05 的发言:[/bo]

不可以呀, 还是一样的错误~~

既然你知道论坛上发帖排版有问题,那就请您动个指头说一下哪个是63行。你不想解决问题我没损失。

程序代码:
<%
   Response.Write("<TR BGCOLOR=#ccccd7>")
   Response.Write("<TD>ID</TD>")
   Response.Write("<TD>username</TD>")
   Response.Write("<TD>title</TD>")
   Response.Write("<TD>text</TD>")
   Response.Write("<TD>createdate</TD>") '这行是你发的代码的63行,我明确地说,这行没有任何问题。
   Response.Write("</TR>")
   For i = 1 to rs.PageSize
       If rs.EOF Then Exit For
       If i mod 2=0 Then
          Color = "#ddddd7"
       Else
          Color = "#eeeeef"
       End If
       Response.Write("<TR BGCOLOR=" + Color + ">")
       Response.Write("<TD>"+rs("ID")+"</TD>")
       Response.Write("<TD>"+rs("username")+"</TD>")
       Response.Write("<TD>"+rs("title")+"</TD>")
       Response.Write("<TD>"+rs("text")+"</TD>")
       Response.Write("<TD>"+rs("createdate")+"</TD>")
       Response.Write("</TR>")
       rs.MoveNext    
   Next
%>
2008-05-18 21:44
星梦玲
Rank: 1
来 自:汕头
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-5-18
收藏
得分:0 
回复 4# 的帖子
不好意思,刚刚没看清楚
它不是说类型不匹配: '[string: "ID"]' 吗?
是不是要把ID转换成字符型?
2008-05-18 21:56
星梦玲
Rank: 1
来 自:汕头
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-5-18
收藏
得分:0 
回复 4# 的帖子
谢谢你~~~可以运行了!!
2008-05-18 22:59
快速回复:请各位帮帮忙?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017714 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved