日期:2014-05-16  浏览次数:20831 次

大家帮忙看看这个程序逻辑哪里不正确呢
两个表:class和smallclass,以classid字段关联。而且现在两个表内已经有关联数据了。

我写下面这个class列表,实现每个父类下面跟子类的功能。
可是,程序却没法运行,页面进度卡死,页面无任何显示:


'前面conn连接数据库代码已经弄好,省略
  <table border="1" width="100%" cellspacing="0" cellpadding="0" class='tableBorder tableBorder-thcenter'>
    <tr><th width="5%"></th>
<th width="10%">类id</th>
<th width="20%">类名称</th>
<th width="20%">类描述</th>
<th width="45%">操作</th>
</tr>
<%
'取得rs记录集----大类名称,id等信息
set rs=server.CreateObject("adodb.recordset")
rs.open "Select * From class",conn,1,3
do while not rs.eof
%>
<tr><td align="center"><img width="16" src="aloesky_IMAGES/folder.png" alt="" /></td>
<td><%=rs("classid")%></td>
<td><%=rs("classname")%></td>
<td><%=rs("dscr")%></td>
<td align="center"></td>
</tr>
<%
'根据classid来关联smallclass小类表,取得相应的小类数据
  set rs1=server.CreateObject("adodb.recordset")
  rs1.open "Select * From smallClass Where classid='" & rs("classid") & "'",conn,1,3
do while not rs1.eof
%>
<tr bgcolor="#E3E3E3><td> - </td>
<td></td>
<td><%=rs1("smallclassname")%></td>
<td><%=rs1("dscr")%></td>
<td align="center"></td>
</tr>
<%
    rs1.movenext
    loop

  call rs1close
rs.movenext
loop

call rscolse
call connclose
%>
  </table>


------解决方案--------------------
代码里有 On Error Resume Next的话,先注释掉,看看会不会报错
------解决方案--------------------
引用:
Quote: 引用:

代码里有 On Error Resume Next的话,先注释掉,看看会不会报错


注释掉了,页面报错:
Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
/a/class_mgr.asp, 第 38 行

这一行是:      rs1.open "Select * From smallClass Where classid='" & rs("classid") & "'",conn,1,3

我看了一下两个表的classid字段类型,都是“整型”,不知道为啥会提示数据类型不匹配呢?


如果都是数字整型,那就应该取消where后面的单引号。
------解决方案--------------------
引用:
Quote: 引用:

代码里有 On Error Resume Next的话,先注释掉,看看会不会报错


注释掉了,页面报错:
Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
/a/class_mgr.asp, 第 38 行

这一行是:      rs1.open "Select * From smallClass Where classid='" & rs("classid") & "'",conn,1,3

我看了一下两个表的classid字段类型,都是“整型”,不知道为啥会提示数据类型不匹配呢?


数字整型是不能用单引号的,你这个是access数据库吧