【问题标题】:BOF - EOF errorBOF - EOF 错误
【发布时间】:2014-08-11 17:58:35
【问题描述】:

当我尝试运行 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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 如何检查 RecordSet 是否为空?非空记录集完全有可能拥有EOF = true
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多