1

我正在尝试使用带有经典 ASP 中以下代码的记录集从数据库中获取数据。我使用的是 windows 7 32 位操作系统:

<%
dim con,rs
set con=Server.Createobject("ADODB.Connection")
con.Provider="Microsoft.Jet.OLEDB.4.0"
con.Open "c:\inetpub\wwwroot\New folder\123.mdb"
rs.Open "select * from student",con
for each x in rs.fields
response.write(x.name)
response.write("=")
response.write(x.value)
next
rs.Close
con.Close
%>

错误是:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/New folder/recordset.asp, line 7
4

1 回答 1

10

VBScript 中没有保留单词“rs”,您必须自己创建记录集。

换行:

rs.Open "select * from student",con

为此:

Set rs = con.Execute("select * from student")

您还只迭代第一条记录,迭代所有记录将代码更改为:

Do Until rs.EOF
    for each x in rs.fields
        response.write(x.name)
        response.write("=")
        response.write(x.value)
        response.write(", ")
    next
    response.write("<br />")
    rs.MoveNext
Loop
于 2013-04-14T07:40:32.457 回答