BOF - EOF错误

时间:2014-06-20 22:07:08

标签: sql asp.net vbscript asp-classic adodb

当我尝试运行SQL查询时,我的asp页面出现此错误:

  

ADODB.Recordset错误'800a0bcd'

     

BOF或EOF为True,或者当前记录已被删除。请求的操作需要当前记录。

代码是:

' -- connect to Database1.accdb database --

set conn1 = server.createobject("adodb.connection")
conn1.open "provider = microsoft.ace.oledb.12.0;data source =  C:\Users\nam2611\Documents\My Web Sites\WebSite1\Database3.accdb"

' -- get product recordset --

set rs1 = server.createobject("ADODB.Recordset")
rs1.open "select * from product where P_code like 'ap'", conn1

x = "<table border = 1 width= 1000><tr><th>code<Th>product name<th>Type<th>Price</Tr>"
response.write x

' -- create the table entries for each student --

rs1.movefirst
while not rs1.eof
    x = "<tr><td>" & rs1("P_code") & "<td>" & rs1("P_name") & "<td>" & rs1("P_description") & "<td>" & rs1("P_price") & "</tr>"
    response.write x
    rs1.movenext
wend
response.write "</table>"

' -- close the datbase --
rs1.close
conn1.close
set rs1 = nothing

1 个答案:

答案 0 :(得分:2)

如果您调用MoveFirst()并且记录集为空,则会引发错误。 您应该检查EOF

If Not rs1.EOF Then
    rs1.movefirst
    ' your loop
    ' ...
End If