死神勇敢的灵魂无料抽:请问一个ASP的问题

来源:百度文库 编辑:高考问答 时间:2024/04/29 20:21:16
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--#include file="conn.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>首页</title>
</head>

<body>

<p>
<a href="say.asp">发表帖子</a>
<br>
<table width=80% cellspacing=1 cellpadding=0 bgcolor=#000000 border="0" align="center">
<tr>
<td width=10% bgcolor="#FFFFFF" align="center">序号</td>
<td width=70% bgcolor="#FFFFFF" align="center">标题</td>
<td width=20% bgcolor="#FFFFFF" align="center">姓名</td>
</tr>
</table>
<br>
<table width=80% cellspacing=1 cellpadding=0 bgcolor=#000000 border="0" align="center">
<%
i=1
set showbbs=conn.execute("select*from index order by id desc")
do while not showbbs.eof
%>
<tr>
<td width=10% bgcolor="#FFFFFF" align="center"><%=showbbs("id")%></td>
<td width=70% bgcolor="#FFFFFF"><%=showbbs("title")%></td>
<td width=20% bgcolor="#FFFFFF" align="center"><%=showbbs("name")%></td>
</tr>
<%
i=i+1
if i>=20 then exit do
showbbs.movenext
loop
showbbs.close
set showbbs=nothing
%>
</table>
</body>
</html>

运行时,报错:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
/index.asp, 第 26 行

*************************************************
其中第 26 行也就是set showbbs=conn.execute("select*from index order by id desc")

请问该如何纠正!谢谢
回答者:不懂_就问啦 - 助理 二级 8-10 17:58

那怎么改啊?

把showbbs=conn.execute("select*from index order by id desc") 做如下改动:
set showbbs=server.createobject("adodb.recordset")
sql="select*from index order by id desc"
showbbs.open sql,conn,1,1

--------------------------------------
新的回复:
经过仔细查看,你原来的set showbbs=conn.execute("select*from index order by id desc") 里,*号左右没空格,不知道原程序里怎样。另外,表名index在这里要用中括号括起来,也就是:
set showbbs=conn.execute("select * from [index] order by id desc")

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--#include file="conn.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>首页</title>
</head>

<body>

<p>
<a href="say.asp">发表帖子</a>
<br>
<table width=80% cellspacing=1 cellpadding=0 bgcolor=#000000 border="0" align="center">
<tr>
<td width=10% bgcolor="#FFFFFF" align="center">序号</td>
<td width=70% bgcolor="#FFFFFF" align="center">标题</td>
<td width=20% bgcolor="#FFFFFF" align="center">姓名</td>
</tr>
</table>
<br>
<table width=80% cellspacing=1 cellpadding=0 bgcolor=#000000 border="0" align="center">
<%
i=1
set showbbs=server.CreateObject("adodb.recordset")
rs.open "select * from index order by id desc",conn,1,1
do while not showbbs.eof
%>
<tr>
<td width=10% bgcolor="#FFFFFF" align="center"><%=showbbs("id")%></td>
<td width=70% bgcolor="#FFFFFF"><%=showbbs("title")%></td>
<td width=20% bgcolor="#FFFFFF" align="center"><%=showbbs("name")%></td>
</tr>
<%
i=i+1
if i>=20 then exit do
showbbs.movenext
loop
showbbs.close
set showbbs=nothing
%>
</table>
</body>
</html>
这里有错:set showbbs=conn.execute

第一、“*”号前后空格;
第二、将记录集改为
Dim objRs
Set objRs = conn.Execute("select * from [index] order by id desc")